Chopper
Chopper is a tool to extract elements from HTML by preserving ancestors and CSS rules.
Compatible with Python >= 3.8
Installation
pip install chopper
Full documentation
Quick start
from chopper.extractor import Extractor
HTML = """
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="header"></div>
<div id="main">
<div class="iwantthis">
HELLO WORLD
<a href="/nope">Do not want</a>
</div>
</div>
<div id="footer"></div>
</body>
</html>
"""
CSS = """
div { border: 1px solid black; }
div#main { color: blue; }
div.iwantthis { background-color: red; }
a { color: green; }
div#footer { border-top: 2px solid red; }
"""
extractor = Extractor.keep('//div[@class="iwantthis"]').discard('//a')
html, css = extractor.extract(HTML, CSS)
The result is :
>>> html
"""
<html>
<body>
<div id="main">
<div class="iwantthis">
HELLO WORLD
</div>
</div>
</body>
</html>"""
>>> css
"""
div{border:1px solid black;}
div#main{color:blue;}
div.iwantthis{background-color:red;}
"""
Metadata
Release files for chopper 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| chopper-0.6.0.linux-x86_64.tar.gz | 22.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| chopper-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.0 kB
Release files / chopper-0.6.0.linux-x86_64.tar.gz
| Download URL | chopper-0.6.0.linux-x86_64.tar.gz |
|---|---|
| Size | 22.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d80edbdbe1775e678c548b548e47f3865f3c21db73d65113fd54e985570d301
|
|
BLAKE2b-256 checksum How to use checksums |
50b9f85a586995dedd16998408d08e07c6c5b6cb2c65cdebc5f7d248faf95240
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Release files / chopper-0.6.0-py3-none-any.whl
| Download URL | chopper-0.6.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
662f87c1922c5661c4560c7b770fb7e59fcc846fe29b0911f865dc80ef664e6e
|
|
BLAKE2b-256 checksum How to use checksums |
9b9db361aa78acb0ea02e456db57e9988a064b527ecd9c266a51ee1ef2f462fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.6
|
Security for chopper 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.