Skip to main content

Scrapy middleware to ignore previously crawled pages

Project description

https://github.com/scrapy-plugins/scrapy-deltafetch/workflows/CI/badge.svg https://img.shields.io/pypi/pyversions/scrapy-deltafetch.svg https://img.shields.io/pypi/v/scrapy-deltafetch.svg https://img.shields.io/pypi/l/scrapy-deltafetch.svg Downloads count

This is a Scrapy spider middleware to ignore requests to pages seen in previous crawls of the same spider, thus producing a “delta crawl” containing only new requests.

This also speeds up the crawl, by reducing the number of requests that need to be crawled, and processed (typically, item requests are the most CPU intensive).

DeltaFetch middleware uses Python’s dbm package to store requests fingerprints.

Installation

Install scrapy-deltafetch using pip:

$ pip install scrapy-deltafetch

Configuration

  1. Add DeltaFetch middleware by including it in SPIDER_MIDDLEWARES in your settings.py file:

    SPIDER_MIDDLEWARES = {
        'scrapy_deltafetch.DeltaFetch': 100,
    }

    Here, priority 100 is just an example. Set its value depending on other middlewares you may have enabled already.

  2. Enable the middleware using DELTAFETCH_ENABLED in your settings.py:

    DELTAFETCH_ENABLED = True

Usage

Following are the different options to control DeltaFetch middleware behavior.

Supported Scrapy settings

  • DELTAFETCH_ENABLED — to enable (or disable) this extension

  • DELTAFETCH_DIR — directory where to store state

  • DELTAFETCH_RESET — reset the state, clearing out all seen requests

These usually go in your Scrapy project’s settings.py.

Supported Scrapy spider arguments

  • deltafetch_reset — same effect as DELTAFETCH_RESET setting

Example:

$ scrapy crawl example -a deltafetch_reset=1

Supported Scrapy request meta keys

  • deltafetch_key — used to define the lookup key for that request. by default it’s Scrapy’s default Request fingerprint function, but it can be changed to contain an item id, for example. This requires support from the spider, but makes the extension more efficient for sites that many URLs for the same item.

  • deltafetch_enabled - if set to False it will disable deltafetch for some specific request

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-deltafetch-2.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

scrapy_deltafetch-2.0.1-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file scrapy-deltafetch-2.0.1.tar.gz.

File metadata

  • Download URL: scrapy-deltafetch-2.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for scrapy-deltafetch-2.0.1.tar.gz
Algorithm Hash digest
SHA256 13f7968bd0ffae133e2a1dede215e683b8c95285f046260603a5c3e25f2d57b0
MD5 a936a4b22066f6b09962543b84bdb190
BLAKE2b-256 4c1654e6d83d28a96e992e807961417c85b59577eee1327aad7da810c250f584

See more details on using hashes here.

File details

Details for the file scrapy_deltafetch-2.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: scrapy_deltafetch-2.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for scrapy_deltafetch-2.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1da535fc801345fd6295a64f20189debe01d0f856a8f4c3c0c2c1d6d1259dcab
MD5 7e6c2c9a35587488bfe57decbe175834
BLAKE2b-256 7e2d9817695c70fa1b216ff038278080afebb51868a60d87459c937a8db52c40

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