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

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

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.