class myhtmlparser(HTMLParser):

    def __init__(self):
        self.reset()
self.NEWTAGS = []
self.NEWATTRS = []
self.HTMLDATA = []

def handle_starttag(self, tag, attrs):
    self.NEWTAGS.append(tag)
self.NEWATTRS.append(attrs)

def handle_data(self, data):
    self.HTMLDATA.append(data)

def clean(self):
    self.NEWTAGS = []
self.NEWATTRS = []
self.HTMLDATA = []
Parsing HTML to get text inside an element