Hello There is a parser on phpQuery

$link = 'mysite.com'; $href_1 = curl($link); $result = phpQuery::newDocument($href_1); $table = $result->find('table')->eq(1)->find('tbody')->find('tr'); foreach ($table as $items) { $items = pq($items); $traider = $items->find('td')->eq(0)->text(); $region = $items->find('td')->eq(1)->text(); $base = $items->find('td')->eq(2)->text(); $name = $items->find('td')->eq(3)->text(); $price = $items->find('td')->eq(4)->text(); $date = $items->find('td')->eq(5)->text(); } 

If you just look for the table -

 $table = $result->find('table')->eq(1) 

then everything is fine, the result returns it (in its pure form, without scripts, etc.). If you add ->find('tr') at the end, it gives

Warning: DOMXPath :: query (): Invalid expression in.

What could be the problem? Thank.

  • Has nobody come across this? - Roma Tulaydan

1 answer 1

Try using:

 $table = $result->find('table')->eq(1)->find('tbody tr'); 
  • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky