Reputation: 2087
I am trying to decode entities using BeautifulSoup but with no luck.
from BeautifulSoup import BeautifulSoup
decoded = BeautifulSoup("<p> </p>",convertEntities=BeautifulSoup.HTML_ENTITIES)
print decoded
The output is not decoded at all. I found a lot of answers here that use this method. Am I a doing something wrong?
I would like to use BeautifulSoup for this so please don't bother telling me that the standard library has a method to decode entities.
Upvotes: 5
Views: 8961
Reputation: 31524
You need to print decoded.contents
:
>>> print decoded
<p> </p>
>>> print decoded.contents
[u'<p> </p>']
Upvotes: 2