Jump to content

Simple HTML DOM Parser 'simple_html_dom.php' Problem


snowman2344

Recommended Posts

I am trying to scrape a page with simple_html_dom.php but have run into a problem. I am looking for an html tag but the page only has an opening tag on some of the elements to be scraped.

EG

<p class=”blue”> blaa blaa blaa<p>

<p class=”blue”>hey hey hey

<p class=”blue”>ha ha ha<p>

 

Note the missing p tag on the second element.

 

I scrape for the class blue and get the following

 

$r = blaa blaa blaa

$s = hey hey hey ha ha ha

$t = ha ha ha

 

What i want is

$r = blaa blaa blaa

$s = hey hey hey

$t = ha ha ha

 

I scrape for the class blue and get the following

How can i scrape this??? I cannot change the html to be scraped.

Thanks in advance

Link to comment
Share on other sites

Thanks for the response. I know how to use the Parser but am running into a specific problem.

 

The problem is that the HTML is coded badly and is missing the closing tag. Therefore the parser is not getting the correct value for each set of tags.

 

As in the following example the closing <P> tag is missing causing the error. Just wondering if the parser can somehow account for this and get the correct values??

 

<p class=”blue”> blaa blaa blaa<p>

<p class=”blue”>hey hey hey                <------------- missing <p>

<p class=”blue”>ha ha ha<p>

 

Values i get

$r = blaa blaa blaa

$s = hey hey hey ha ha ha            <-------------- Wrong

$t = ha ha ha

 

Values i want

$r = blaa blaa blaa

$s = hey hey hey

$t = ha ha ha

 

 

 

 

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.