I have a html text like this:
<xml ... >
and I want to convert it to something readable:
<xml ...>
Any easy (and fast) way to do it in Python?
I have a html text like this:
<xml ... >
and I want to convert it to something readable:
<xml ...>
Any easy (and fast) way to do it in Python?
Official documentation for HTMLParser
: Python 3
>>> from html import unescape
>>> unescape('© €')
© €
Official documentation for HTMLParser
: Python 3
>>> from html.parser import HTMLParser
>>> pars = HTMLParser()
>>> pars.unescape('© €')
© €
Note: this was deprecated in the favor of html.unescape()
.
Official documentation for HTMLParser
: Python 2.7
>>> import HTMLParser
>>> pars = HTMLParser.HTMLParser()
>>> pars.unescape('© €')
u'\xa9 \u20ac'
>>> print _
© €
Modern Python 3 approach:
>>> import html
>>> html.unescape('© €')
© €