Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing html page in php

Today when I was parsing one page with Simple HTML DOM parser I didn't get any result. So I thought, that it must be strange. So I went to see HTML code written there. I found that there's many mistakes.

So here comes the question. What to do in state, when parser works correctly, but HTML is a mess. Maybe some one would suggest some aproach or some other parser which is able to handle, that sort of matters.

Thank you all for help.

like image 253
Eugene Avatar asked Apr 22 '26 17:04

Eugene


1 Answers

Run it through tidy before trying to load it into a DOM tree, http://php.net/manual/en/book.tidy.php

like image 125
David Gillen Avatar answered Apr 24 '26 06:04

David Gillen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!