ukscotth Posted August 3, 2011 Share Posted August 3, 2011 Hi, Im having a nightmare trying to scrape some data from the freelancer.com website. I only need to scrape the job titles but for some reason it isnt working. usually I would just do something like this : $html = new DOMDocument(); @$html->loadHtmlFile('http://www.freelancer.com/sellers/'); $xpath = new DOMXPath( $html ); $nodelist = $xpath->query( "//div[@class='title']" ); foreach ($nodelist as $n){ echo $n->nodeValue."\n"; echo '<br>'; } Its just showing blank results. Any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/243704-xpath-problem/ Share on other sites More sharing options...
premiso Posted August 3, 2011 Share Posted August 3, 2011 Why are you suppressing errors? @$html->loadHtmlFile('http://www.freelancer.com/sellers/'); Remove that @ sign and see what error it is throwing. If freelancer.com does not have valid HTML, the DOM will not work with it. Quote Link to comment https://forums.phpfreaks.com/topic/243704-xpath-problem/#findComment-1251264 Share on other sites More sharing options...
ukscotth Posted August 3, 2011 Author Share Posted August 3, 2011 Sorry not sure how that @ got there. It just shows a blank page when i run it Quote Link to comment https://forums.phpfreaks.com/topic/243704-xpath-problem/#findComment-1251266 Share on other sites More sharing options...
premiso Posted August 3, 2011 Share Posted August 3, 2011 Well try echoing out some variables, see if stuff is being populated. Other debugging techniques also work, such as a var_dump etc. Quote Link to comment https://forums.phpfreaks.com/topic/243704-xpath-problem/#findComment-1251272 Share on other sites More sharing options...
ukscotth Posted August 3, 2011 Author Share Posted August 3, 2011 Shouldnt the echo $n->nodeValue."\n"; part already echo something out ? Sorry if im being stoopid. Quote Link to comment https://forums.phpfreaks.com/topic/243704-xpath-problem/#findComment-1251275 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.