Adapted from beautifulsoup4's inner package, then linted, refactored, reduced, and seasoned to taste.
To run pre-commit checks and tests:
pre-commit run --all-files && pdm run python -m pytest
To parse a string as HTML, your recipe should call for CampbellsSoup
:
from campbells import CampbellsSoup
html_str = "<html><body><p>Hello world!</p></body></html>"
soup = CampbellsSoup(html_str)
Campbells is available on PyPi:
pip install campbells
The dependencies needed to use html5lib
and lxml
parsers are not installed by default.
They can be installed with: