Registry / serialization / sgmllib3k

sgmllib3k

JSON →
library1.0.0pypypi✓ verified 25d ago

sgmllib3k is a Python 3 port of the `sgmllib` module, which was deprecated in Python 2.6 and removed in Python 3.0. It provides a basic SGML/HTML parser for legacy applications. The current version is 1.0.0, released in 2011, and the project appears to be abandoned.

pip install sgmllib3k
INSTALL
IMPORT
SIG · SGMLLIB3K
S
sgmllib3k
serializationpythonv1.0.0
Install
2.4s avg
Import
10ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.006s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.006s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SGMLParser
from sgmllib import SGMLParser
from sgmllib3k import SGMLParser

This quickstart demonstrates how to create a basic parser by subclassing `SGMLParser` and overriding methods like `handle_data` to process the parsed content. The `feed()` method is used to pass the HTML string to the parser.

import sgmllib3k class MyParser(sgmllib3k.SGMLParser): def __init__(self, verbose=0): sgmllib3k.SGMLParser.__init__(self, verbose) self.data = [] def handle_data(self, data): self.data.append(data) def unknown_starttag(self, tag, attrs): # Example: print all start tags pass def unknown_endtag(self, tag): # Example: print all end tags pass html_content = "<html><body><h1>Hello</h1><p>World</p></body></html>" parser = MyParser() parser.feed(html_content) parser.close() print("Extracted data:", parser.data) # Expected output: Extracted data: ['Hello', 'World']
Debug
Known issues
breakingsgmllib3k is not actively maintained and was last updated in 2011. It is designed for early Python 3 versions (e.g., 3.0-3.2) and may not be compatible or stable with modern Python 3.x releases (3.6+).
fix
For new development or modern web parsing, consider the standard library's `html.parser` or third-party libraries like `BeautifulSoup`.
affects: <=1.0.0
deprecatedThis library itself is a port of a deprecated module (`sgmllib`). It lacks modern features like HTML5 support, robust error handling, and performance optimizations found in contemporary parsing libraries. Its use is strongly discouraged for new projects.
fix
Migrate to `html.parser` for basic HTML parsing or `BeautifulSoup` for more comprehensive and fault-tolerant parsing of real-world HTML documents.
affects: <=1.0.0
gotchaUnlike `html.parser` or `BeautifulSoup`, `sgmllib3k` (and the original `sgmllib`) provides a very low-level, SAX-like parser. It requires manual implementation of handler methods (e.g., `start_tag`, `end_tag`, `handle_data`) which can be verbose and error-prone for complex parsing tasks.
fix
Be prepared to write significant boilerplate code for custom parsing logic. Evaluate if `html.parser`'s `HTMLParser` or `BeautifulSoup`'s DOM-like interface would simplify your task considerably.
affects: <=1.0.0
Upgrade
Version history
1.0.0latest on PyPI · released Aug 24, 2010
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
2
Resources
sgmllib3k — pip install sgmllib3k · libregistry