<jupyter_start><jupyter_text>**.handle_comment(data)**This method is called when a comment is encountered (e.g. ).The data argument is the content inside the comment tag:    from HTMLParser import HTMLParser    class MyHTMLParser(HTMLParser):        def handle_comment(self, data):              print "Comment  :", data**.handle_data(data)**This method is called to process arbitrary data (e.g. text nodes and the content of ... and ...).The data argument is the text content of HTML.    from HTMLParser import HTMLParser    class MyHTMLParser(HTMLParser):        def handle_data(self, data):            print "Data     :", data<jupyter_code>from html.parser import HTMLParser

class MyHTMLParser(HTMLParser):
    
    def handle_comment(self, comment):
        
        if '\n' in comment:
            print('>>> Multi-line Comment')
        else:
            print(' Single-line Comment')
            
        print(comment)
        
    
    def handle_data(self, data):
        
        if data == '\n': return
        print('>>> Data')
        print(data)
        
        
html = ""

for _ in range(int(input())):
    html += input().rstrip()
    html += '\n'
    
parser = MyHTMLParser()
parser.feed(html)
parser.close()<jupyter_output>4
<!--[if IE 9]>IE9-specific content
<![endif]-->
<div> Welcome to HackerRank</div>
<!--[if IE 9]>IE9-specific content<![endif]-->
>>> Multi-line Comment
[if IE 9]>IE9-specific content
<![endif]
>>> Data
 Welcome to HackerRank
 Single-line Comment
[if IE 9]>IE9-specific content<![endif]
{'fraction_non_alphanumeric': 0.1300653594771242, 'fraction_numerical': 0.0058823529411764705, 'mean_word_length': 2.725060827250608, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '513200', 'license': 'MIT', 'n_tokens_mistral': 448, 'n_tokens_neox': 437, 'n_words': 140, 'path': 'Python/13. regex and parsing/84. html parser part 2.ipynb', 'repo_name': 'faisalsanto007/Hakcerrank-problem-solving', 'size': '1530'}