Skip to main content

Two stage Scrapy spider: download and extract

Project description

Have you ever written a web scraper, only to find out after a long time that there’s some extra data on the pages you should’ve been scraping all along?

Or a change on a website means your scraper stops working, and you lose days or weeks of data until you can find the time to fix it?

This library aims to solve this problem by splitting a Scrapy scraper up into two asynchronous stages:

  1. Download stage - The website is crawled, and the pages to be scraped are downloaded and saved to disk.

  2. Extract stage - The pages to be scraped are loaded from disk. The desired data is extracted from the pages and exported (e.g. to a file or database).

The crawler logic for the download stage should be kept as simple as possible. It would typically open a known URL and perform very simple actions such as clicking a “next page” button or submitting a search query. This reduces the risk of the downloader breaking if there are minor changes made to the website.

And since all of the raw data is being saved, if you ever decide to change your extractor logic, you can simply re-run the extractor on all of the data that has been downloaded.

Installation

Downloading and installing from PyPI

To install using pip:

$ pip install scrapy-twostage

Or to install using easy_install:

$ easy_install scrapy-twostage

Downloading and installing from source

Download the latest version of scrapy-twostage from http://pypi.python.org/pypi/scrapy-twostage/.

You can install it by doing the following:

$ tar xvfz scrapy-twostage-0.0.0.tar.gz
$ cd scrapy-twostage-0.0.0
# python setup.py install # as root

Using the development version

You can clone the git repository by doing the following:

$ git clone git://github.com/acordiner/scrapy-twostage.git

Using scrapy-twostage

Coming soon…

Bug tracker

If you have any suggestions, bug reports or annoyances please report them at http://github.com/acordiner/scrapy-twostage/issues/

License

This software is licensed under the GPL v2 License. See the LICENSE file in the top distribution directory for the full license text.

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

scrapy-twostage-0.0.4.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file scrapy-twostage-0.0.4.tar.gz.

File metadata

File hashes

Hashes for scrapy-twostage-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9c7e43ed1bdb3906030af562cb488c29aadd4fa916e4643dc40ac811c05f5984
MD5 f6be4cfb6804522445c3bde1047f1c3c
BLAKE2b-256 9d23fd935c8442ad9093f7c357ea7a26dbc7d4e03df526eaa40db3f1c0654a69

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