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

Discussion in 'Python' started by Stefan Behnel, Mar 29, 2010.

  1. Stéphane Klein, 29.03.2010 10:12:
    > I work on HTML cleaner.
    >
    > I export OpenOffice.org documents to HTML.
    > Next, I would like clean this HTML export files :
    >
    > * remove comment
    > * remove style
    > * remove dispensable tag
    > * ...
    >
    > some difficulty :
    >
    > * convert <p>my text <span>foo</span> bar</p> => <p>my text foo par</p>
    > * convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>
    >
    > to do this process, I use lxml and pyquery.


    lxml.html has tools for that in the 'clean' module. Just specify the list
    of tags that you want to discard.


    > * are there some xml helper tools in Python to do this process ? I've
    > looked for in pypi, I found nothing about it


    The HTML tools in the standard library are close to non-existant. You can
    achieve some things with the builtin tools, but if they fail for a
    particular input document, there's little you can do.


    > If you confirm than this tools don't exists, I'll maybe publish a helper
    > package to do this "clean" processing.


    Take a look at lxml.html.clean first.

    Stefan
    Stefan Behnel, Mar 29, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Al Moritz
    Replies:
    7
    Views:
    634
    Richard Laing
    Jul 22, 2003
  2. Ivan Voras

    HTML cleaner?

    Ivan Voras, Apr 25, 2005, in forum: Python
    Replies:
    7
    Views:
    840
    Terry Hancock
    Apr 26, 2005
  3. mttc
    Replies:
    2
    Views:
    2,386
    Roedy Green
    Jul 3, 2009
  4. Stéphane Klein
    Replies:
    2
    Views:
    1,757
    John Nagle
    Mar 30, 2010
  5. Nagraj Kini

    Changing the time for the html span title tag

    Nagraj Kini, Oct 13, 2003, in forum: Javascript
    Replies:
    1
    Views:
    253
    Thomas 'PointedEars' Lahn
    Oct 14, 2003
Loading...

Share This Page