HTMLParser
raw JSON → 0.0.2 verified Mon Apr 27 auth: no python abandoned
Backport of Python 2.7's HTMLParser to earlier versions. Version 0.0.2 is the latest release, with no active development. Intended for legacy Python 2.x compatibility only; not maintained for Python 3.
pip install htmlparser Common errors
error ImportError: No module named HTMLParser ↓
cause Trying to import using the Python 2.7 standard library module name (uppercase) instead of the backport module name (lowercase).
fix
Use 'from htmlparser import HTMLParser' (note lowercase 'h').
error ImportError: No module named htmlparser ↓
cause The backport package is not installed or is not available for Python 3.
fix
Install with 'pip install htmlparser' for Python 2, or use Python 3's built-in 'html.parser' module.
Warnings
breaking This library is a backport of Python 2.7's HTMLParser. It is not compatible with Python 3. Do not use in Python 3 projects. ↓
fix Use Python 3's built-in html.parser.HTMLParser instead.
deprecated The library is unmaintained since 2012. No bug fixes or security patches are expected. ↓
fix Migrate to Python 3's html.parser or consider using html5lib for modern HTML parsing.
Imports
- HTMLParser wrong
from HTMLParser import HTMLParsercorrectfrom htmlparser import HTMLParser
Quickstart
from htmlparser import HTMLParser
class MyParser(HTMLParser):
def handle_starttag(self, tag, attrs):
print("Start tag:", tag)
parser = MyParser()
parser.feed('<html><head><title>Test</title></head></html>')