Skip to main content

Parsel is a library to extract data from HTML and XML using XPath and CSS selectors

Project description

Tests Supported Python versions PyPI Version Coverage report

Parsel is a BSD-licensed Python library to extract data from HTML, JSON, and XML documents.

It supports:

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']

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parsel-1.11.0.tar.gz (106.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parsel-1.11.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

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

Hashes for parsel-1.11.0.tar.gz
Algorithm Hash digest
SHA256 5925fe087eb16fc404a7ed91e31e2c1e2a9b230da4b64f34d81358c0d0e27e88
MD5 b154f0c24f3c810cb52ba250097eebc2
BLAKE2b-256 91c84ace3a5c61e39ca21734a5715d0e076eea6200dd8daea2a5b99452f5a0d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for parsel-1.11.0.tar.gz:

Publisher: publish.yml on scrapy/parsel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for parsel-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bda82575df1774dd64e1c1396163f3cadb3e383e0f8080d43d45fa6705355daa
MD5 5a79b1144bbcf1c012a93fe7a09877a5
BLAKE2b-256 08234e0dae5e5bee14aea26dba003a682e621563451a20f751ed985810f818b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for parsel-1.11.0-py3-none-any.whl:

Publisher: publish.yml on scrapy/parsel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page