Friday 3 August 2018

How to parse content from page using CURL?

How to get data from this ?



1,234,567



I need to get statsTopHi data? but dont know how to do it, i'm new to php and dont know anything about curl.



    $handle = curl_init();
curl_setopt($handle, CURLOPT_URL, "my url");
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($handle);
curl_close($handle);

$DOM = new DOMDocument;

$DOM->loadHTML($html);

//get all span
$items = $DOM->getElementsByTagName('span');

//display all span text
for ($i = 0; $i < $items->length; $i++)
echo $items->item($i)->nodeValue . "
";
?>



Using this i parse all span content, but need to get only class="statsTopHi"

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...