mardi 27 mars 2018

How to gather the value of a specific from a variable containing the complete web page code

I scraped a web page with the price of bitcoin and have the complete web page code stored in a variable. How do I extract the span:

<span class="text-large2" data-currency-value>8128.61</span>

from the whole code? By the way the number 8128.61 changes every time the page is refreshed as the price is updated

Here is my full code:

$.getJSON('http://www.whateverorigin.org/get?url=' + encodeURIComponent('https://coinmarketcap.com/currencies/bitcoin/') + '&callback=?', function(data){
        console.log(data.contents);
});
body {
    background-color: lightblue;
}
<!DOCTYPE html>
<html>
<body>
<html lang="en">

<head>
  <title>Web Scraper</title>
  <link rel="stylesheet" href="css/style.css">
</head>

<body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/scripts.js"></script>
</body>

</html>
</body>



Aucun commentaire:

Enregistrer un commentaire