This appears to be the same question as Python code to remove HTML tags from a string which points to Strip HTML from strings in Python
Copying the top answer from that question gives:
I always used this function to strip HTML tags, as it requires only the Python stdlib:
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()