Good HTML Parser
stefan_ml at behnel.de
Thu Jul 17 17:04:08 CEST 2008
> Can anyone recommend a good HTML/XHTML parser, similar to
> HTMLParser.HTMLParser or htmllib.HTMLParser, but able to intelligently
> know that certain tags, like <br>, are implicitly closed? I need to
> iterate through the entire DOM, building up a DOM path, but the stdlib
> parsers aren't calling handle_endtag() for any implicitly closed tags.
> I looked at BeautifulSoup, but it only seems to work by first parsing
> the entire document, then allowing you to query the document
> afterwards. I need something like a SAX parser.
Try lxml.html. It's very memory friendly and extremely fast, so you may end up
without any reason to use SAX anymore.
More information about the Python-list