Prabhakar Prabhakar - 7 months ago 60
HTML Question

Decode HTML string using python 2.7

I want the following HTML string to be decoded with HTML tags

\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e

How can I do that in Python 2.7 ?

I am having large HTML string to decode. The above sample is just a apart of that.

PS: I have tried with many solutions available in web to decode HTML string but nothing helps me EDIT:
I have referred this Decode HTML entities in Python string?


You can try:

>>>text = "\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e".decode('unicode-escape')
>>>print text
u'<p><strong><span>About the Company </span></strong></p>'