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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.