Skip to main content

XML/HTML scraper using XPath queries.

Project description

Piculet

Piculet is a package for extracting data from XML documents using XPath queries. It can also scrape web pages by first converting the HTML source into XHTML. Piculet consists of a single source file with no dependencies other than the standard library, which makes it very easy to integrate into applications.

Piculet requires Python 3.4 or later. You can install the latest version from PyPI:

pip install piculet

Or, if you like, you can install the development version from the Bitbucket repository:

pip install hg+https://bitbucket.org/uyar/piculet

To extract data from a document, you need to specify the rules for extraction. This specification is in JSON format and you can find a few examples in the examples folder.

Although Piculet is primarily aimed at developers, it also contains a command-line interface where data extraction can be tested. To get an idea about how Piculet works, get the wikipedia.json specification example and run the command given below to get some data out of the Wikipedia page for David Bowie:

$ python piculet.py scrape "https://en.wikipedia.org/wiki/David_Bowie" -s wikipedia.json -r person --html
{
  "birthplace": "Brixton, London, England",
  "born": "1947-01-08",
  "died": "2016-01-10",
  "name": "David Bowie",
  "occupation": [
    "Singer",
    "songwriter",
    "actor"
  ]
}

Installing Piculet through pip will create a script named piculet which can also be used to invoke the command-line interface:

$ piculet scrape "https://en.wikipedia.org/wiki/John_Lennon" -s wikipedia.json -r person --html

For a more complicated example, get the imdb.json specification and run the following command to get details about the movie The Shining:

$ piculet scrape "http://akas.imdb.com/title/tt0081505/combined" -s imdb.json -r movie_combined --html

History

1.0a2 (2017-04-04)

  • Added support for Python 2.7.

  • Fixed lxml support.

1.0a1 (2016-08-24)

  • First release on PyPI.

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

piculet-1.0a2.tar.gz (31.0 kB view details)

Uploaded Source

File details

Details for the file piculet-1.0a2.tar.gz.

File metadata

  • Download URL: piculet-1.0a2.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for piculet-1.0a2.tar.gz
Algorithm Hash digest
SHA256 1cfb2a6d1d85b7702ca66f0ac831be6bf414ef1ca1bcb1fb17e55843759026a2
MD5 2f6f09aeb9286d153131d461f95faf57
BLAKE2b-256 b398fad42739c11d580a4d168e8f385b3143a4e0109cb6a13162b9190a6761a3

See more details on using hashes here.

Supported by

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