Skip to content

Instantly share code, notes, and snippets.

@codecakes
Created June 18, 2016 09:13
Show Gist options
  • Select an option

  • Save codecakes/4670cdfe5a52bda7a6fbd5869c7f5fde to your computer and use it in GitHub Desktop.

Select an option

Save codecakes/4670cdfe5a52bda7a6fbd5869c7f5fde to your computer and use it in GitHub Desktop.
If you had a filter to filter all htm incoming raw string using BeautifulSoup
from __future__ import unicode_literals
from BeautifulSoup import BeautifulStoneSoup
def html_decoder(s):
return BeautifulStoneSoup(s, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
if __name__ == "__main__":
s = "U.S. Adviser’s Blunt Memo on Iraq: Time ‘to Go Home’"
print html_decoder(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment