I am trying to pull an exact table during a "web scrape." Used cURL to pull page into $html, which succeeds fine.
Used Firebug to get exact XPATH to the table needed.
Code follows:
$dom = new DOMDocument($html);
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
$summary = $xpath->evaluate('/html/body/table[5]/tbody/tr/td[3]/table/tbody/tr[8]/td/table');
echo "Summary Length: " . $summary->length;
When executed, $summary->length is always zero. It doesn't pull that table node.
Any ideas?
Firefox is liable to insert "virtual" tbody elements into tables that don't have them; do those elements exist in the original file?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With