Skip to main content

htmlsift

Web main-content extraction: HTML in, clean text / HTML / markdown out. A small model, trained on WebMainBench, scores each rendered line of a page as main content or boilerplate (nav, ads, cookie banners, and footers) and returns just the content.

Apache-2.0. Full documentation, diagrams, and benchmarks: https://github.com/koivualeksi/htmlsift

Install

pip install htmlsift          # default: the mini model (CPU, ONNX)
pip install htmlsift[full]    # adds the base 311M model (torch; GPU-capable)
  • htmlsift — the mini model only; a small install (onnxruntime + tokenizers + lxml + numpy + huggingface-hub). First use downloads ~230 MB of model files.
  • htmlsift[full] — adds torch + transformers to run base. First use of base downloads ~1 GB.

Requires Python 3.10+. Model files download from the Hugging Face Hub on first use and are cached; run htmlsift download <mode> to prefetch, or set HF_HUB_OFFLINE=1 to run from cache only.

Usage

from htmlsift import Extractor

ex = Extractor()                     # defaults to "mini"
ex.extract(html)                     # -> str (plain text)
ex.extract(html, output="html")      # structure, links, images kept
ex.extract(html, output="markdown")  # clean markdown: [text](url), ![alt](src)
ex.extract(html, with_blocks=True)   # -> (blocks, probs)

import htmlsift
htmlsift.extract(html)               # module-level convenience

The larger model, from htmlsift[full]:

ex = Extractor("base")               # 311M encoder; GPU when present, else CPU (with a warning)
ex = Extractor("base", device="cuda")  # require the GPU

mini is CPU-only; only base runs on the GPU.

Output modes

output what you get
text (default) selected content as plain text
html selected DOM, with structure / links / images kept
markdown clean markdown, links and images preserved

License

Apache-2.0. Model weights are distributed separately, from the Hugging Face Hub.

Metadata

Release files for htmlsift 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for htmlsift 0.1.0
File Size Uploaded
htmlsift-0.1.0.tar.gz 43.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for htmlsift 0.1.0
File Interpreter ABI Platform
htmlsift-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.6 kB

Release files / htmlsift-0.1.0.tar.gz

Download URL htmlsift-0.1.0.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a505dc9a013159a4359f6ea438a8357dc9c9187a821138d911a177dac0262d9b
BLAKE2b-256 checksum
How to use checksums
408232aafd03e353ad38c115684764e1e02f45212a21e85e949d941f47e09b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / htmlsift-0.1.0-py3-none-any.whl

Download URL htmlsift-0.1.0-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4c82ca772a3e0904305a3a9d6ffc4f60a4c1e09cb8856ede35bc027d2b84371c
BLAKE2b-256 checksum
How to use checksums
217873a17f824d0499ba2d40a98b511bd9e0a6f0ea1e11ae8d499404ba471cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page