Jump to content

xpath problem


ukscotth

Recommended Posts

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.