Parsel is a library to extract data from HTML and XML using XPath and CSS selectors
Project description
Parsel is a BSD-licensed Python library to extract data from HTML, JSON, and XML documents.
It supports:
JMESPath expressions for JSON documents
Find the Parsel online documentation at https://parsel.readthedocs.org.
Example (open online demo):
>>> from parsel import Selector
>>> text = """
... <html>
... <body>
... <h1>Hello, Parsel!</h1>
... <ul>
... <li><a href="http://example.com">Link 1</a></li>
... <li><a href="http://scrapy.org">Link 2</a></li>
... </ul>
... <script type="application/json">{"a": ["b", "c"]}</script>
... </body>
... </html>"""
>>> selector = Selector(text=text)
>>> selector.css("h1::text").get()
'Hello, Parsel!'
>>> selector.xpath("//h1/text()").re(r"\w+")
['Hello', 'Parsel']
>>> for li in selector.css("ul > li"):
... print(li.xpath(".//@href").get())
...
http://example.com
http://scrapy.org
>>> selector.css("script::text").jmespath("a").get()
'b'
>>> selector.css("script::text").jmespath("a").getall()
['b', 'c']
Project details
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parsel-1.11.0.tar.gz.
File metadata
- Download URL: parsel-1.11.0.tar.gz
- Upload date:
- Size: 106.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5925fe087eb16fc404a7ed91e31e2c1e2a9b230da4b64f34d81358c0d0e27e88
|
|
| MD5 |
b154f0c24f3c810cb52ba250097eebc2
|
|
| BLAKE2b-256 |
91c84ace3a5c61e39ca21734a5715d0e076eea6200dd8daea2a5b99452f5a0d6
|
Provenance
The following attestation bundles were made for parsel-1.11.0.tar.gz:
Publisher:
publish.yml on scrapy/parsel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parsel-1.11.0.tar.gz -
Subject digest:
5925fe087eb16fc404a7ed91e31e2c1e2a9b230da4b64f34d81358c0d0e27e88 - Sigstore transparency entry: 869393882
- Sigstore integration time:
-
Permalink:
scrapy/parsel@05b3d37bf292d012f3d0b71fb7f0697d03af113e -
Branch / Tag:
refs/tags/v1.11.0 - Owner: https://github.com/scrapy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05b3d37bf292d012f3d0b71fb7f0697d03af113e -
Trigger Event:
push
-
Statement type:
File details
Details for the file parsel-1.11.0-py3-none-any.whl.
File metadata
- Download URL: parsel-1.11.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda82575df1774dd64e1c1396163f3cadb3e383e0f8080d43d45fa6705355daa
|
|
| MD5 |
5a79b1144bbcf1c012a93fe7a09877a5
|
|
| BLAKE2b-256 |
08234e0dae5e5bee14aea26dba003a682e621563451a20f751ed985810f818b6
|
Provenance
The following attestation bundles were made for parsel-1.11.0-py3-none-any.whl:
Publisher:
publish.yml on scrapy/parsel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
parsel-1.11.0-py3-none-any.whl -
Subject digest:
bda82575df1774dd64e1c1396163f3cadb3e383e0f8080d43d45fa6705355daa - Sigstore transparency entry: 869393884
- Sigstore integration time:
-
Permalink:
scrapy/parsel@05b3d37bf292d012f3d0b71fb7f0697d03af113e -
Branch / Tag:
refs/tags/v1.11.0 - Owner: https://github.com/scrapy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@05b3d37bf292d012f3d0b71fb7f0697d03af113e -
Trigger Event:
push
-
Statement type: