2017-01-07 19:11:46 +08:00
|
|
|
import html.parser
|
2015-01-28 20:35:27 +08:00
|
|
|
|
2014-11-05 09:56:00 +08:00
|
|
|
try:
|
2017-01-07 19:11:46 +08:00
|
|
|
HTMLParseError = html.parser.HTMLParseError
|
2014-11-05 09:56:00 +08:00
|
|
|
except AttributeError:
|
|
|
|
# create a dummy class for Python 3.5+ where it's been removed
|
|
|
|
class HTMLParseError(Exception):
|
|
|
|
pass
|
2012-07-20 22:16:57 +08:00
|
|
|
|
2012-02-01 04:36:11 +08:00
|
|
|
|
2017-01-07 19:11:46 +08:00
|
|
|
class HTMLParser(html.parser.HTMLParser):
|
2016-12-01 18:38:01 +08:00
|
|
|
"""Explicitly set convert_charrefs to be False.
|
|
|
|
|
2017-01-22 09:02:00 +08:00
|
|
|
This silences a deprecation warning on Python 3.4.
|
2016-12-01 18:38:01 +08:00
|
|
|
"""
|
|
|
|
def __init__(self, convert_charrefs=False, **kwargs):
|
2017-01-07 19:11:46 +08:00
|
|
|
html.parser.HTMLParser.__init__(self, convert_charrefs=convert_charrefs, **kwargs)
|