0

I am using a software called Visual Web Ripper to select element i need from a webpage. But i do not use Visual Web Ripper to scrape the elements, I just want to get the XPATH from there of the elements I need and then use that in our own engine. But it does not seem to work. See screen shots below.

Getting XPATH from Visual Web Ripper for the elements i want to scrape

enter image description here

The code I am using in PHP

$curl = new curl();
$html = $curl->get_web_page('http://forums.fatakat.com/');

$doc = new DOMDocument();
$doc->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>'.$html);

$xpath = new DOMXpath($doc);

$elements = $xpath->query("//TABLE[@class='tborder']/TBODY/TR[@class='']/TD[2]/DIV[1]/A[1]/STRONG[1]");

////$elements = $xpath->query("//*[@id='f3']"); //works

if (!is_null($elements)) {
  foreach ($elements as $element) {
    echo "<br/>[". $element->nodeName. "]";

    $nodes = $element->childNodes;
    foreach ($nodes as $node) {
      echo $node->nodeValue. "\n";
    }
  }
}

Thanking you

4

0 回答 0