Skip to main content

XPath is a Python DSL around a subset of XPath 1.0. Its primary purpose is to facilitate writing complex XPath queries from Python code.

build

Generating expressions

To create expressions, use the generators in xpath.dsl:

from xpath import dsl as x
from xpath.renderer import to_xpath

expression = x.descendant("ul")[x.attr("id") == "foo"]
xpath = to_xpath(expression)

HTML

XPath comes with a set of premade XPaths for use with HTML documents.

You can generate these like this:

from xpath.html import button
from xpath.renderer import to_xpath

to_xpath(button("Save"), exact=True)

See xpath.html for all available matchers.

License

(The MIT License)

Copyright © 2010 Jonas Nicklas

Copyright © 2016 Ian Lesperance

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release files for xpath-py 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xpath-py 0.1.2
File Size Uploaded
xpath-py-0.1.2.tar.gz 10.8 kB Details

Release files / xpath-py-0.1.2.tar.gz

Download URL xpath-py-0.1.2.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6e111a0be0df610d3fad7acf03f2e5dcaeec1b6d724a708a397f838dc0c463fa
BLAKE2b-256 checksum
How to use checksums
9edc9f056e5ca38816a0b87fdd94d8902b054f6e0db30ac99810b7a5f1516ea8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page