Skip to main content

Define download_delay for different domain.

Project description

Scrapy-Domain-Delay

Build Status

Install

$ pip install scrapy-domain-delay

Usage

Step 1: Extract only the domain name from a url using Python tldextract.

>>> import tldextract
>>> tldextract.extract('https://www.google.com/').domain
'google'

Step 2: Use the following config values in your scrapy settings:

  1. Enable the AutoThrottle extension.

    AUTOTHROTTLE_ENABLED = True
    
  2. Enable the Custom Delay Throttle by adding it to EXTENSIONS.

    EXTENSIONS = {
        'scrapy.extensions.throttle.AutoThrottle': None,
        'scrapy_domain_delay.extensions.CustomDelayThrottle': 300,
    }
    
  3. Add {'domain': 'download delay (in seconds)'} to the DOMAIN_DELAYS.

    something like:

    # set up custom delays per domain
    DOMAIN_DELAYS = {
        'google': 1.0,
    }
    

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-domain-delay-0.0.2.tar.gz (2.0 kB view hashes)

Uploaded Source

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