views:

258

answers:

3

I have a cherrypy web server that uses larges amounts of HTML data. Is there anyway in Python to minimize the HTML so that all comments, spaces, ext, are removed?

A: 

HTML Tidy's libtidy doesn't seem to have python bindings (bit it does have perl and c++ etc), but ought to be easy to run as an exe in a pipe.

Or ideally, use it to 'tidy' all static html files once so they don't need to be tidied each time they are served.

Will
That page links to a *TidyLib Python wrapper*: http://utidylib.berlios.de/ but I don't know if it minifies.
Andrea Ambu
+3  A: 

Not what you mean, but: Gzip. (Assuming you aren't already serving through a compressing front-end.) Compression will zip away whitespace to almost nothing; unless you have excessively large comments this will be more effective than minification.

bobince
+2  A: 

there are bindings to tidy for python, called mxTidy from eGenix (Marc André Lemburg)

ghum