I'm trying to work out if there is a better way to achieve the following:
from lxml import html
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup("<p>£682m</p>")
text = soup.find("p").string
print text
>>> £682m
print html.fromstring(text).text
>>> £682m
So I'm trying to produce the same string that lxml returns when I do the second print. I'd rather not have to resort to lxml in order to interpret these escaped characters: can anyone provide a way of doing this with something in the standard library?
[edit: I've accepted luc's answer but both are valid: I just thought that the answer that made use of the standard library was probably more useful in a generic sense]