lxml-html
a html parser based lxml
Element is a wrapper of lxml.html.HtmlElement
Element implement a proxy of HtmlElement
install
pip install lxmlHtml
quick start
from lxmlHtml import Element
text = """
<div>
<span></span>
<span></span>
<span></span>
</div>
"""
element = Element.fragment_fromstring(text)
# add some attribute
first_span = element.cssselect('span')[0]
print(first_span)
first_span.set('width', '200px')
first_span.styles.set('font-size', '20px')
first_span.styles.set('max-width', '200px')
first_span.classes.add('red')
first_span.classes.add('green')
# remove element
element.xpath_first('//span[2]').drop_tag()
# # get children
print(element.getchildren())
# # add element
last_span = element.xpath_first("//span[last()]")
print(last_span)
ele = element.makeelement("p")
c = element.makecomment("p")
last_span.append(ele)
last_span.append(c)
# serialize
print(element.tostring(pretty_print=True))
"""
<div>
<span width="200px" style="font-size: 20px; max-width: 200px;" class="red green"></span>
<span><p></p>
<!--p--></span>
</div>
"""
Metadata
Release files for lxmlHtml 0.0.2
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 | Actions |
|---|---|---|---|---|
| lxmlHtml-0.0.2.tar.gz | 5.4 kB | Without provenance | Details for lxmlHtml-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lxmlHtml-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for lxmlHtml-0.0.2-py3-none-any.whl |
Total release size: 11.0 kB
Release files / lxmlHtml-0.0.2.tar.gz
| Download URL | lxmlHtml-0.0.2.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be004cd74860bd40fee5cb4747bef654ccfdcddbda55fbce9a048f2f72d9f4c8
|
|
BLAKE2b-256 checksum How to use checksums |
abc5381006df4f5d06d29825fdaf827a59a5afc20203da3f14008db7da521ff5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0
|
Release files / lxmlHtml-0.0.2-py3-none-any.whl
| Download URL | lxmlHtml-0.0.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6407ac58a2b08d228aedecc203bc31b2d2f5318f3d288c1d33bd10d4fa044dd2
|
|
BLAKE2b-256 checksum How to use checksums |
d18db23f0d17f863014b028cb1da45fcbfd043f43b7f0cec2d8eb6a3fe271c2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0
|
Security for lxmlHtml 0.0.2
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.