Metadata-Version: 2.4
Name: parsel
Version: 1.11.0
Summary: Parsel is a library to extract data from HTML and XML using XPath and CSS selectors
Project-URL: Homepage, https://github.com/scrapy/parsel
Project-URL: Documentation, https://parsel.readthedocs.io/en/latest/
Project-URL: Source, https://github.com/scrapy/parsel
Project-URL: Tracker, https://github.com/scrapy/parsel/issues
Project-URL: Release notes, https://parsel.readthedocs.io/en/latest/history.html
Author-email: Scrapy project <info@scrapy.org>
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: parsel
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Text Processing :: Markup :: HTML
Classifier: Topic :: Text Processing :: Markup :: XML
Requires-Python: >=3.10
Requires-Dist: cssselect>=1.2.0
Requires-Dist: jmespath>=1.0.0
Requires-Dist: lxml>=5.1.0
Requires-Dist: packaging>=23.0
Requires-Dist: w3lib>=1.19.0
Description-Content-Type: text/x-rst

======
Parsel
======

.. image:: https://github.com/scrapy/parsel/actions/workflows/tests-ubuntu.yml/badge.svg
   :target: https://github.com/scrapy/parsel/actions/workflows/tests-ubuntu.yml
   :alt: Tests

.. image:: https://img.shields.io/pypi/pyversions/parsel.svg
   :target: https://github.com/scrapy/parsel/actions/workflows/tests.yml
   :alt: Supported Python versions

.. image:: https://img.shields.io/pypi/v/parsel.svg
   :target: https://pypi.python.org/pypi/parsel
   :alt: PyPI Version

.. image:: https://img.shields.io/codecov/c/github/scrapy/parsel/master.svg
   :target: https://codecov.io/github/scrapy/parsel?branch=master
   :alt: Coverage report


Parsel is a BSD-licensed Python_ library to extract data from HTML_, JSON_, and
XML_ documents.

It supports:

-   CSS_ and XPath_ expressions for HTML and XML documents

-   JMESPath_ expressions for JSON documents

-   `Regular expressions`_

Find the Parsel online documentation at https://parsel.readthedocs.org.

Example (`open online demo`_):

.. code-block:: pycon

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

.. _CSS: https://en.wikipedia.org/wiki/Cascading_Style_Sheets
.. _HTML: https://en.wikipedia.org/wiki/HTML
.. _JMESPath: https://jmespath.org/
.. _JSON: https://en.wikipedia.org/wiki/JSON
.. _open online demo: https://colab.research.google.com/drive/149VFa6Px3wg7S3SEnUqk--TyBrKplxCN#forceEdit=true&sandboxMode=true
.. _Python: https://www.python.org/
.. _regular expressions: https://docs.python.org/library/re.html
.. _XML: https://en.wikipedia.org/wiki/XML
.. _XPath: https://en.wikipedia.org/wiki/XPath
