I am trying to scrape the rating from this particular page
https://www.zomato.com/ncr/between-buns-sda-new-delhi
which is in this code here
<div tabindex="0" aria-label="Rated" data-res-id="18559961" class="rating-for-18559961 rating-div rrw-aggregate level-7">
4.0<span>/5</span> </div>
I am trying to use aria-label="rated" to scrape as class has a very long name but its returning empty result
here is my code
<?php
$curl = curl_init('https://www.zomato.com/ncr/between-buns-sda-new-delhi');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$page = curl_exec($curl);
if(!empty($curl)){ //check html return
$zomato_doc = new DOMDocument;
libxml_use_internal_errors(true);
$zomato_doc->loadHTML($page);
libxml_clear_errors(); //remove errors
$zomato_xpath = new DOMXPath($zomato_doc);
$rate = $zomato_xpath->query('//div[contains(@aria-label,"Rated")]');
if($rate->length > 0) {
$node = $rate->item(0);
echo "{$node->nodeName} - {$node->nodeValue}";
}
else {
// empty result set
echo "no result bro";
}
}
else {
print "Not found";
}
?>
But everytime I get No result bro as answer, it never parses the information. Please help