Re: I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>…

John Nagle nagle at
Tue Mar 30 02:35:09 CEST 2010

Stéphane Klein wrote:
> Hi,
> I work on HTML cleaner.
> I export documents to HTML.
> Next, I would like clean this HTML export files :
> * remove comment
> * remove style
> * remove dispensable tag
> * ...

    Try parsing with HTML5 Parser ("") which
is the closest thing to a good parser available for Python.  It's basically
a reference implementation of HTML5, including all the handling of bad HTML.

    Once you have a tree, write something to go through the tree and remove
empty tags from a list of tags which do nothing when empty.  Then
regenerate HTML from the tree.

    Or just use HTML Tidy: ""

					John Nagle

More information about the Python-list mailing list