MainContentExtractor
A library to extract the main content from html. Developed for information on LLM and for feeding data into LangChain and LlamaIndex.
What it is and what it does
MainContentExtractor wraps trafilatura to extract the main article or content body from HTML pages while preserving structural information like links and headers. Unlike trafilatura alone, it can output in HTML format (via an XML intermediate step), plain text, or Markdown—formats more suitable for feeding into LLM frameworks. It depends on trafilatura for core extraction, html2text for text conversion, and beautifulsoup4 for HTML parsing.
The library addresses a specific gap: trafilatura is effective at identifying main content but cannot output HTML directly and sometimes loses necessary data. MainContentExtractor compensates by converting trafilatura's XML output to HTML, though this conversion is not perfectly reversible. It's designed for workflows where you need both structured content and multiple output formats, particularly when preparing web data for language models.
Use it for:
- Prepare web articles for ingestion into LangChain or LlamaIndex by extracting clean content in Markdown or text format.
- Extract main content from HTML while preserving link and header hierarchy for downstream analysis or indexing.
- Convert web pages to Markdown for easier consumption by LLM prompts or knowledge bases.
- Remove boilerplate, navigation, and ads from web pages before processing with NLP tools.
- Build web scraping pipelines that output multiple formats from a single extraction pass.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts main content from HTML pages and outputs it in HTML, text, or Markdown format, preserving element hierarchy and link information for use with LLM frameworks.
Yes, if you need HTML-format output from main content extraction for LLM workflows. The library fills a real gap and has low install friction. However, proceed with caution: the package has been dormant since 2023-12-10 with no updates, maintenance status is unclear, and the XML-to-HTML conversion is lossy. Evaluate whether trafilatura alone or an alternative meets your needs before committing to a package with uncertain long-term support.
Install
maincontentextractor on PyPI
pip
pip install maincontentextractoruv
uv add maincontentextractorpoetry
poetry add maincontentextractorInstalling MainContentExtractor
Before you install
Low install friction with three straightforward dependencies. Package is dormant since its single release on 2023-12-10, with no updates despite a recent commit on 2024-05-16; maintenance status is unclear and future updates are uncertain.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install MainContentExtractor
from main_content_extractor import MainContentExtractor
extracted_html = MainContentExtractor.extract(html_content)
extracted_markdown = MainContentExtractor.extract(html_content, output_format="markdown")
Verify before relying
- Whether the May 2024 commit represents ongoing development or a one-time fix after the December 2023 release.
- How the XML-to-HTML conversion affects data fidelity in practice and whether the irreversibility is a significant limitation.
- Whether output quality and format preservation meet requirements compared to using trafilatura directly.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — trafilatura, html2text, beautifulsoup4 |
| Maintenance | dormant — 978 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 79,301/month — #14,367 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: MainContentExtractor-0.0.4-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
trafilaturaTrafilatura extracts main text, metadata, and…
permissive · top 5,000 on PyPI
jusTextjusText removes boilerplate content…
permissive · top 5,000 on PyPI
pymupdf4llmConverts PDFs and documents into clean,…
agpl · top 1,000 on PyPI
langextractLangExtract uses LLMs to extract and ground…
permissive · top 15,000 on PyPI
semantic-text-splitterSplits long text into semantically meaningful…
permissive · top 15,000 on PyPI
Crawl4AICrawl4AI is an async web crawler and scraper…
permissive · top 5,000 on PyPI
langchain-tavilyIntegrates Tavily's web search and content…
permissive · top 15,000 on PyPI
inscriptisConverts HTML documents to plain text while…
permissive · top 5,000 on PyPI
html-textExtracts plain text from HTML while filtering…
permissive · top 5,000 on PyPI
pdfminerExtracts text and layout information from PDF…
permissive · top 15,000 on PyPI