Skip to content

Instantly share code, notes, and snippets.

@erogol
Created November 4, 2013 00:53
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 erogol/7296578 to your computer and use it in GitHub Desktop.
Save erogol/7296578 to your computer and use it in GitHub Desktop.
HTML stripper in Python
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()
@ostwalprasad
Copy link

It helped. Thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment