parsel
Parsel is a library to extract data from HTML and XML using XPath and CSS selectors
What it is and what it does
Parsel is a data extraction library that wraps HTML, JSON, and XML documents in a unified selector interface. It lets you query documents using CSS selectors and XPath expressions for markup, JMESPath for JSON, and regular expressions across all formats. The library is commonly used in web scraping pipelines and data processing workflows where you need to pull structured information from semi-structured documents.
The package depends on lxml for markup parsing, cssselect for CSS-to-XPath translation, jmespath for JSON queries, w3lib for URL/encoding utilities, and packaging for version handling. It supports modern Python versions (3.10 through 3.14) and both CPython and PyPy implementations. The API is straightforward: create a Selector from text, then chain method calls like .css() or .xpath() to navigate and extract data.
Use it for:
- Web scraping: extract product names, prices, and links from e-commerce HTML pages.
- API response parsing: pull nested data from JSON responses using JMESPath expressions.
- XML document processing: extract fields from structured XML feeds or configuration files.
- Data cleaning pipelines: apply CSS or XPath rules to normalize and extract text from HTML documents.
- Testing web scrapers: validate that selectors correctly target expected elements before deploying.
- Log or markup analysis: search and extract patterns from HTML or XML logs using regular expressions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parsel extracts data from HTML, JSON, and XML documents using CSS selectors, XPath expressions, JMESPath queries, and regular expressions.
Yes. Parsel is actively maintained, widely used (top 5000 PyPI), has no known vulnerabilities, and offers a clean API for a common task. Install it if you need to extract data from HTML, XML, or JSON documents in a Python application. The low install friction and permissive license make it a straightforward choice.
Install
parsel on PyPI
pip
pip install parseluv
uv add parselpoetry
poetry add parselInstalling parsel
Before you install
Low friction install with five runtime dependencies (cssselect, jmespath, lxml, packaging, w3lib). Active maintenance with recent commits and stable production status.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions.
Quickstart
pip install parsel
from parsel import Selector
text = '<h1>Hello</h1><ul><li><a href="http://example.com">Link</a></li></ul>'
selector = Selector(text=text)
print(selector.css('h1::text').get())
print(selector.xpath('//a/@href').get())
Requires Python 3.10 or later; lxml is a compiled C dependency that may require build tools on some systems.
Verify before relying
- Whether lxml compilation is seamless on all target platforms or if pre-built wheels are reliably available.
- Performance characteristics when parsing very large documents or applying complex selector chains.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — cssselect, jmespath, lxml, packaging, w3lib |
| Maintenance | actively maintained — 197 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,934,763/month — #2,196 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: parsel-1.11.0-py3-none-any.whl
Keywords: parsel
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
cssselectcssselect parses CSS3 selectors and translates…
permissive · top 1,000 on PyPI
itemloadersItemloaders extracts and standardizes…
permissive · top 5,000 on PyPI
jmespathJMESPath is a query language for extracting and…
permissive · top 100 on PyPI
selectolaxselectolax is a fast HTML5 parser with CSS…
permissive · top 5,000 on PyPI
pyquerypyquery lets you query and manipulate XML and…
permissive · top 5,000 on PyPI
cssselect2cssselect2 parses and matches CSS4 selectors…
permissive · top 1,000 on PyPI
turbohtmlParse, query, edit, and serialize HTML and XML…
permissive · top 15,000 on PyPI
elementpathProvides XPath 1.0, 2.0, 3.0, and 3.1 selectors…
permissive · top 5,000 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
inscriptisConverts HTML documents to plain text while…
permissive · top 5,000 on PyPI