Skip to content

Instantly share code, notes, and snippets.

@mrchilds
Created February 3, 2012 09:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchilds/1729289 to your computer and use it in GitHub Desktop.
Save mrchilds/1729289 to your computer and use it in GitHub Desktop.
Strip all HTML from string using BeautifulSoup
from BeautifulSoup import BeautifulSoup
body = "<p>Dear Everyone,</p><p>This is a test</p><h1>Test Complete</h1>"
plain_text = ' '.join(BeautifulSoup(body).findAll(text=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment