chopper 0.2.0
pip install chopper==0.2.0
Newer version available (0.6.0)
Released:
Lib to extract html elements by preserving ancestors and cleaning CSS
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: UNKNOWN
- Author: Jurismarchés
Classifiers
- Development Status
- Programming Language
Project description
Extracts html contents by preserving ancestors and clean CSS
Compatible with Python >= 2.6, <= 3.4
Installation
pip install chopper
Usage
from chopper 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;}
"""
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: UNKNOWN
- Author: Jurismarchés
Classifiers
- Development Status
- Programming Language
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file chopper-0.2.0.tar.gz
.
File metadata
- Download URL: chopper-0.2.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
fec7c008042f3202a17ebc6ec3cf319760b9a6d2f027ef5ffb64c30693e86fa7
|
|
MD5 |
331a09160ee97f144e1f92cafb5e2382
|
|
BLAKE2b-256 |
eb2998413e3139ad4521d1b51ce1a7f07765358a0c094f4102cb4e40c8d3fff2
|