snowman2344 Posted January 30, 2012 Share Posted January 30, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/256056-simple-html-dom-parser-simple_html_domphp-problem/ Share on other sites More sharing options...
darkfreaks Posted January 30, 2012 Share Posted January 30, 2012 http://net.tutsplus.com/tutorials/php/html-parsing-and-screen-scraping-with-the-simple-html-dom-library/ is this what you are looking for Quote Link to comment https://forums.phpfreaks.com/topic/256056-simple-html-dom-parser-simple_html_domphp-problem/#findComment-1312675 Share on other sites More sharing options...
snowman2344 Posted January 31, 2012 Author Share Posted January 31, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/256056-simple-html-dom-parser-simple_html_domphp-problem/#findComment-1312811 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.