BoilerPy3 is an active Python port of Christian Kohlschütter's Boilerpipe library, designed for robust HTML boilerplate removal and main text extraction from web pages. It is currently at version 1.0.7 and is based on Boilerpipe 1.2 functionality. The library focuses on providing a more Pythonic interface, including type-hinting and snake_case conventions.
pip install boilerpy3Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to extract content from both a raw HTML string and a URL. For URL extraction, it is highly recommended to use the `requests` library for robust fetching, then pass the HTML content to the extractor.
Use `requests` or a similar library to fetch HTML, then process with `extractor.get_content(html_string)`.
Explicitly set `raise_on_failure=True` or `raise_on_failure=False` in the `Extractor` constructor based on desired error handling. If your code expects exceptions for all failures, ensure it's `True`.
Review any code that might have accessed internal or undocumented camelCase attributes and update them to their snake_case equivalents if they were exposed. Stick to documented public APIs to avoid such issues.
Be aware that the underlying algorithm is equivalent to Boilerpipe 1.2. If a specific Boilerpipe 1.3 feature is needed, it might not be available in `boilerpy3`.
Ensure you have installed `boilerpy3` using `pip install boilerpy3` and that your import statements are `from boilerpy3 import extractors`.
Consider passing `raise_on_failure=False` to your `Extractor` constructor (e.g., `extractors.ArticleExtractor(raise_on_failure=False)`) to gracefully handle errors and retrieve any partial content. Also, try different extractors like `DefaultExtractor` or `KeepEverythingExtractor`.
Upgrade to the latest `boilerpy3` version (v1.0.5 or later fixed `set_is_content`). For other `AttributeError`s related to internal names, ensure you are using the documented public API and check if a camelCase attribute was converted to snake_case.