Skip to main content
2025 Python Packaging Survey is now live!  Take the survey now

API to extract content from HTML & XML documents

Project description

Selection Documenation

Travis CI Test coverage

API to query DOM tree of HTML/XML document.

Usage Example

from selection import XpathSelector
from lxml.html import fromstring

html = '<div><h1>test</h1><ul id="items"><li>1</li><li>2</li></ul></div>'
sel = XpathSelector(fromstring(html))
print(sel.select('//h1')).text()
print(sel.select('//li').text_list()
print(sel.select('//ul').attr('id')

Installation

Run: pip install -U selection

Community

Telegram English chat: https://t.me/grablab

Telegram Russian chat: https://t.me/grablab_ru

Supported by

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