i am trying to grab links from the Google search page. i am using the be below xpath to
//div[@id='ires']/ol[@id='rso']/li/h3/a/@href
grab the links. xPather evaluates it and gives the result. But when i use it with my php it doesn't show any result. Can someone please tell me what I am doing wrong? There is nothing wrong with the cURL.
below is my code
$dom = new DOMDocument();
@$dom->loadHTML($result);
$xpath=new DOMXPath($dom);
$elements = $xpath->evaluate("//div[@id='ires']/ol[@id='rso']/li/h3/a");
foreach ($elements as $element)
{
$link = $element->getElementsByTagName("href")->item(0)->nodeValue;
echo $link."<br>";
}
Sample Html provided by Robert Pitt
<li class="g w0">
<h3 class="r">
<a href="" class="l"><em>LINK</em></a>
</h3>
<button class="ws" title=""></button>
<div class="s">
META
</div>
</li>