You are viewing a single comment's thread. Return to all comments →
from html.parser import HTMLParser class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print(f"Start : {tag}" + "".join([f"\n-> {attr[0]} > {attr[1]}" for attr in attrs if attrs])) def handle_endtag(self, tag): print(f"End : {tag}") def handle_startendtag(self, tag, attrs): print(f"Empty : {tag}" + "".join([f"\n-> {attr[0]} > {attr[1]}" for attr in attrs if attrs])) if __name__ == '__main__': html = "" parser = MyHTMLParser() for _ in range(int(input())): html += input() parser.feed(html)
Seems like cookies are disabled on this browser, please enable them to open this website
HTML Parser - Part 1
You are viewing a single comment's thread. Return to all comments →