symfony - Having problems filtering by xPath -
i'm trying build hacker news scraper using symfony 2's dom crawler [1]
when try out xpath chrome plugin [2], works. when try in scraper keep getting the current node list empty.
here's scraper code:
$crawler1 = $client1->request('get','https://news.ycombinator.com/item?id=8296437'); $hnpost->selftext = $crawler1->filterxpath('/html/body/center/table/tbody/tr[3]/td/table[1]/tbody/tr[4]/td[2]')->text();
[1] http://api.symfony.com/2.0/symfony/component/domcrawler/crawler.html#method_filter [2] https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl?hl=en-us
if problem think is, i've been battered 1 couple of times. chrome implicitly adds missing <tbody>
tags dom, if copy xpath or css path, may have copied tags don't exist in source document. try viewing page's source , see if dom reported browser's console corresponds original source html. if <tbody>
tags absent, sure exclude them in filterxpath()
call.
Comments
Post a Comment