skillfed

parsel

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

parsel v1.11.0 4.9M downloads/30d#2,196 on PyPI1,349
Permissive license BSD-3-Clause Active released

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 parsel

uv

uv add parsel

poetry

poetry add parsel

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Text Processing :: MarkupTopic :: Text Processing :: Markup :: HTMLTopic :: Text Processing :: Markup :: XML

Tags

html parsing css xpathextract data from html xmlweb scraping selector libraryjson jmespath extractiondocument parsing selectorshtml xml data extractioncss xpath json queries
web-scrapingdata-extractionmarkup-parsing

More Markup packages