Re: unescape HTML entities

Discussion in 'Python' started by Fredrik Lundh, Oct 29, 2006.

  1. Rares Vernica wrote:

    > How can I unescape HTML entities like " "?


    run it through an HTML parser.

    or use something like this:

    http://effbot.org/zone/re-sub.htm#strip-html

    (if you want to keep elements, change the regular expression in the
    re.sub call to "(?s)&#?\w+;")

    > I know about xml.sax.saxutils.unescape() but it only deals with "&",
    > "<", and ">".
    >
    > Also, I know about htmlentitydefs.entitydefs, but not only this
    > dictionary is the opposite of what I need, it does not have " ".


    >>> htmlentitydefs.entitydefs.get("nbsp")

    '\xa0'

    </F>
     
    Fredrik Lundh, Oct 29, 2006
    #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. Rares Vernica

    unescape HTML entities

    Rares Vernica, Oct 28, 2006, in forum: Python
    Replies:
    4
    Views:
    886
    Klaus Alexander Seistrup
    Nov 1, 2006
  2. Rares Vernica

    Re: unescape HTML entities

    Rares Vernica, Nov 2, 2006, in forum: Python
    Replies:
    0
    Views:
    409
    Rares Vernica
    Nov 2, 2006
  3. Frederic Rentsch

    Re: unescape HTML entities

    Frederic Rentsch, Nov 2, 2006, in forum: Python
    Replies:
    0
    Views:
    649
    Frederic Rentsch
    Nov 2, 2006
  4. Jim Higson
    Replies:
    3
    Views:
    251
    Eric Amick
    Jul 25, 2004
  5. Philipp

    Escape/ Unescape HTML?

    Philipp, Dec 20, 2007, in forum: Javascript
    Replies:
    2
    Views:
    266
    Thomas 'PointedEars' Lahn
    Dec 21, 2007
Loading...

Share This Page