human
I am working on the file "HTML_and_JSON_processing.ipynb".
The first task is:
Simle example of usage follows. Following parser print out encountered tags and data.
Can you write Python code for it?
 ... Can you provide a Python code to print out encountered tags and data?
assistant
#Here is Python code to print out encountered tags and data.

# from HTMLParser import HTMLParser # Python 2.7
from html.parser import HTMLParser

class TestHTMLParser(HTMLParser):
    
    def handle_starttag(self, tag, attrs):
        print("Tag start:", tag)

    def handle_endtag(self, tag):
        print("Tag end:", tag)

    def handle_data(self, data):
        print("Tag data:", data)
    
# instantiate the parser and fed in some HTML
parser = TestHTMLParser(convert_charrefs=True)
parser.feed(sample_html)