HTML Reader Mode
A Python library to extract the main content from an HTML document, similar to the "Reader Mode" feature found in web browsers. It filters out navigation, ads, sidebars, and other non-content elements.
Installation
pip install html-reader-mode
Usage
from html_reader_mode import HTMLReaderMode
html_content = """
<html>
<body>
<div id="header">Header content</div>
<div id="content">
<h1>Article Title</h1>
<p>This is the main content of the article.</p>
</div>
<div id="footer">Footer content</div>
</body>
</html>
"""
reader = HTMLReaderMode()
content = reader.sanitize(html_content)
print(content)
# Output:
# [{'tag': 'h1', 'content': 'Article Title'}, {'tag': 'p', 'content': 'This is the main content of the article.'}]
Features
- Content Extraction: Identifies and extracts the main text blocks.
- Noise Reduction: Removes scripts, styles, and high-link-density blocks (like navigation menus).
- Customizable: Configure block tags, script tags, and filtering thresholds.
License
MIT
Metadata
Release files for html-reader-mode 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| html_reader_mode-0.1.1.tar.gz | 7.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| html_reader_mode-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.8 kB
Release files / html_reader_mode-0.1.1.tar.gz
| Download URL | html_reader_mode-0.1.1.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4aed5029907097a785b09145b6ffcaed628da8d65d1dd0533408b09043bf49a2
|
|
BLAKE2b-256 checksum How to use checksums |
83dfee50a691effbc4f4a243dc2791a2074e864a06d76d267a86b858e70815ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / html_reader_mode-0.1.1-py3-none-any.whl
| Download URL | html_reader_mode-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b1bb5018418eb0c906053bcce2b661df9ef76f67c8a8855db856034c3c450e3f
|
|
BLAKE2b-256 checksum How to use checksums |
9f25fd364bcc8a8e8a10393238d59c806128d57c5abf9101e5bd934f7042ad20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|