MainContentExtractor is a Python library designed to extract the core content from HTML documents. It aims to address limitations found in other extraction tools, such as the inability to output clean HTML directly. The library is useful for LLM-related tasks and for feeding data into frameworks like LangChain and LlamaIndex by providing output in HTML, Text, or Markdown formats. It is currently at version 0.0.4, with a relatively active development cadence.
pip install MainContentExtractorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to extract the main content from an HTML string using MainContentExtractor. It shows output in HTML, Markdown, and plain text formats. If fetching HTML from a URL, ensure `requests` is installed (`pip install requests`).
Be aware that the output HTML might not be an exact replica of the original main content. Validate the extracted output against your specific use case, especially if pixel-perfect fidelity to the original HTML is required.
Always use `pip install MainContentExtractor` for installation and `from main_content_extractor import MainContentExtractor` for importing. Pay close attention to casing and underscores.
Pin your project's dependency to a specific patch version (e.g., `MainContentExtractor==0.0.4`) and thoroughly test your application after any updates. Monitor the GitHub repository for release notes and changes.
Ensure the package is installed with the correct casing using `pip install MainContentExtractor`. Then, verify your Python import statement matches the installed module, for example: `from main_content_extractor import MainContentExtractor`.
Confirm `maincontentextractor` is installed correctly, specifically using the casing `pip install MainContentExtractor`. If using a virtual environment, ensure it's activated and the package is present.
Install the required sub-dependency by running: `pip install lxml_html_clean`.