Skip to content

Instantly share code, notes, and snippets.

@kwyn
Created April 27, 2014 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwyn/11358208 to your computer and use it in GitHub Desktop.
Save kwyn/11358208 to your computer and use it in GitHub Desktop.
from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def get_data(self):
return ''.join(self.fed)
def strip_tags(html):
s = MLStripper()
s.feed(html)
return s.get_data()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment