Skip to main content

scrapy-requests-spider-closed is an extension to make requests when the spider is closed

Project description

scrapy-requests-spider-closed

scrapy-requests-spider-closed is an extension to make requests when the spider is closed.

Use cases:

  • You must make a request to an API when the spider is closed.
  • You make a request to an API when the scraping is finished, your API will create a report with the data scraped.
  • Etc.

Installation

Install scrapy-requests-spider-closed using pip:

pip install git+https://github.com/XavierZambrano/scrapy-requests-spider-closed.git

Configuration

  1. Add the REQUESTS_SPIDER_CLOSED_REASONS_TRIGGER in your settings.py file.
REQUESTS_SPIDER_CLOSED_REASONS_TRIGGER = ['finished', 'cancelled', 'shutdown']

The REQUESTS_SPIDER_CLOSED_REASONS_TRIGGER is a list of reasons that will trigger the requests. reasons.

  1. Add the REQUESTS_SPIDER_CLOSED_REQUESTS_PARAMETERS in your settings.py file.
REQUESTS_SPIDER_CLOSED_REQUESTS_PARAMETERS = [
    {
        'method': 'POST',
        'url': 'https://myapi-xxx.com/endpoint',
    }
]

You can use any parameter that the requests library accepts.

  1. Enable SpiderClosedRequests by adding it to the EXTENSIONS in your settings.py file.
EXTENSIONS = {
   "scrapy_requests_spider_closed.RequestsSpiderClosed": 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_requests_spider_closed-0.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file scrapy_requests_spider_closed-0.0.1.tar.gz.

File metadata

File hashes

Hashes for scrapy_requests_spider_closed-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7d865c331cbb89ab787966a3086cb9e2dbbbc0e0a5b83204782a2063201b55aa
MD5 61ecbaab2ebbdb87277e24a2557cfec6
BLAKE2b-256 5ac67d40f7ee40713f85d73e4b2be47e43b54e3ff115c6894b096f89459ab361

See more details on using hashes here.

File details

Details for the file scrapy_requests_spider_closed-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for scrapy_requests_spider_closed-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d913acd769117fc0e358b14ca9d0f916ca70428446df4bacffac14b0f1b5e113
MD5 dc7b6755aab0ce3999b76c27c1926b28
BLAKE2b-256 8ab122a5c8b616b91f000421af37f3401dc0ae7426db42f0581a21ade0e06808

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