Created
November 4, 2013 00:53
-
-
Save erogol/7296578 to your computer and use it in GitHub Desktop.
HTML stripper in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
It helped. Thanks man!