Skip to main content

Python library for generating XPath expressions

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpath-py-0.1.2.tar.gz (10.8 kB view details)

Uploaded Source

File details

Details for the file xpath-py-0.1.2.tar.gz.

File metadata

  • Download URL: xpath-py-0.1.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for xpath-py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6e111a0be0df610d3fad7acf03f2e5dcaeec1b6d724a708a397f838dc0c463fa
MD5 ed5557fabeca7b0ff291ca5d28899f97
BLAKE2b-256 9edc9f056e5ca38816a0b87fdd94d8902b054f6e0db30ac99810b7a5f1516ea8

See more details on using hashes here.

Supported by

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