[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/sofay/learn-python3/master/samples/commonlib/use_htmlparser.py [Back]  [Original]

#!/usr/bin/env python3 # -*- coding: utf-8 -*- from html.parser import HTMLParser from html.entities import name2codepoint class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print('' % tag) def handle_endtag(self, tag): print('' % tag) def handle_startendtag(self, tag, attrs): print('' % tag) def handle_data(self, data): print(data) def handle_comment(self, data): print('') def handle_entityref(self, name): print('&%s;' % name) def handle_charref(self, name): print('&#%s;' % name) parser = MyHTMLParser() parser.feed('''

Some html HTML tutorial...
END

''')
Web Proxy Viewer  |  New URL  |  Original Page