scrapy-redirect restricts authorized HTTP redirections to the website start_urls
Why?
If the Scrapy REDIRECT_ENABLED config key is set to False and a request to the homepage of the crawled website returns a 3XX status code, the crawl will stop immediatly, as the redirection will not be followed.
scrapy-redirect will force Scrapy to tolerate redirections coming from the start_urls urls, in the case where REDIRECT_ENABLED = False, to avoid this particular problem.
Installation
$ pip install scrapy-redirect
Configuration
Install scrapy-redirect in your Scrapy middlewares by adding the following key/value pair in the SPIDER_MIDDLEWARES settings key (in settings.py):
SPIDER_MIDDLEWARES = {
...
'scrapyredirect.HomepageRedirectMiddleware': 575,
...
}
Note that it is important for the middleware order value to be inferior to 600 (the default value of the 'scrapy.contrib.downloadermiddleware.redirect.RedirectMiddleware' middleware), as it must be executed before Scrapy blocks the redirection.
NB: if REDIRECT_ENABLED = True, scrapy-redirect does nothing.
License
scrapy-redirect is published under the MIT License.
Metadata
Release files for scrapy-redirect 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scrapy-redirect-0.1.0.tar.gz | 3.2 kB | Without provenance | Details for scrapy-redirect-0.1.0.tar.gz |
Release files / scrapy-redirect-0.1.0.tar.gz
| Download URL | scrapy-redirect-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4eb733d867925794b0598738da518374d35199db5af4a04f62235352db67b2d2
|
|
BLAKE2b-256 checksum How to use checksums |
d0371b6b6ee64a0fbf37eb408c298dfddb04b22f5b2f989d8a6b948d32c70780
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for scrapy-redirect 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.