jamie_lynn
asked on
What is the best HTML parser for PHP?
Hi,
What is the best html parser for PHP? Something like BeautifulSoup for Python.
Thanks
Jamie
What is the best html parser for PHP? Something like BeautifulSoup for Python.
Thanks
Jamie
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well.. I want to parser that can search on tag name, attribute, or value.
....
<div id="rating">
</div>
....
i.e. divcontent = soup.findAll("div", { "id" : "rating" })
Then search again from the results
Is there a html parser in PHP that does this?
Thanks
Jamie
....
<div id="rating">
</div>
....
i.e. divcontent = soup.findAll("div", { "id" : "rating" })
Then search again from the results
Is there a html parser in PHP that does this?
Thanks
Jamie
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks hernst. Can this handle messy html that everyone write on the web? I was thinking about using dom parsers but I was reading that dom parsers does not do well with poor html.
i.e. No end tag, unquoted values, etc
Thanks
Jamie
i.e. No end tag, unquoted values, etc
Thanks
Jamie
If you have poor html, you could 1st use tidy to make it better html and then use it in dom. If the html is so poor that tidy fails, the user should fix it. No parser can do such things.
I'm glad I could help. Thanks for the fun question, grade and points.
bol
bol
http://www.info4php.com/?req=PHP_Editors