so I\'m very new to php. But with some help, I\'ve figured out how to scrape a site if it has a tag identifier like h1 class=____
And even better, I\'ve figured out how
if you only care about that change percentage, try this and remove the whole foreach
section:
$query = "//tr[@id='id-ethereum']/td[contains(@class, 'percent-24h')]";
$entries = $xpath->query($query);
echo $entries->item(0)->getAttribute('data-usd'); //-5.15
here are the rest of the columns:
$xpath = new DOMXPath($doc);
$market_cap = $xpath->query("//tr[@id='id-ethereum']/td[contains(@class, 'market-cap')]");
echo $market_cap->item(0)->getAttribute('data-usd'); //30574084827.1
$price = $xpath->query("//tr[@id='id-ethereum']/td/a[contains(@class, 'price')]");
echo $price->item(0)->getAttribute('data-usd'); //329.567
$circulating_supply = $xpath->query("//tr[@id='id-ethereum']/td/a[@data-supply]");
echo $circulating_supply->item(0)->getAttribute('data-supply'); //92770467.9991
$volume = $xpath->query("//tr[@id='id-ethereum']/td/a[contains(@class, 'volume')]");
echo $volume->item(0)->getAttribute('data-usd'); //810454000.0
$percent_change = $xpath->query("//tr[@id='id-ethereum']/td[contains(@class, 'percent-24h')]");
echo $percent_change->item(0)->getAttribute('data-usd'); //-3.79