-3

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 https://stackoverflow.com/a/2087433/4350834 and got the result as

\u003cp\u003e\u003cstrong\u003e\u003cspan\u003eAbout the Company \u003c/span\u003e\u003c/strong\u003e\u003c/p\u003e
Community
  • 1
  • 1
Prabhakar
  • 1,138
  • 2
  • 14
  • 30

1 Answers1

3

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>'
nick_gabpe
  • 5,113
  • 5
  • 29
  • 38