Middleware to easily implement ScraperAPI in Scrapy projects
Project description
scrapy-scraperapi-middleware
This middleware lets you use Scraper API for every request you process with Scrapy.
You could instead set the proxy
field of your request's meta attribute to http://scraperapi.your=options:your_key@proxy-server.scraperapi.com:8001
and enable HttpProxyMiddleware
.
This middleware's only purpose is to achieve this in a more convenient manner.
Installation
$ pip install scrapy-scraperapi-middleware
Settings
You need to specify your key for Scraper API in your settings.py or settings object.
SCRAPERAPI_KEY = 'your_key'
You also need to enable ScrapyScraperAPIMiddleware as well as Scrapy's HttpProxyMiddleware.
DOWNLOADER_MIDDLEWARES = {
'scrapy_scraperapi_middleware.ScrapyScraperAPIMiddleware': 350,
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 400,
}
Additional options
Scraper API supports additional options as documented here. You could use these options by adding them to your settings as dictionary.
SCRAPERAPI_OPTIONS = {
'render': 'true',
'country_code': 'us'
}
Affiliate link
If this example is helpful to you and you do not yet have a subscription to Scraper API, consider using my affiliate link if you plan on getting one. Be aware that all other links to ScraperAPI in this Readme are also affiliate links.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scrapy-scraperapi-middleware-1.0.tar.gz
.
File metadata
- Download URL: scrapy-scraperapi-middleware-1.0.tar.gz
- Upload date:
- Size: 3.4 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.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 529ed7eca82a2c2865ff51fb5d54b744bbb80a65cedec45bf5ba86e03aa5ce1a |
|
MD5 | c801fcb6d984017f1320c1c2b8a37e1d |
|
BLAKE2b-256 | 6648ac1f258a86c8b78182ff0ab3a4409a9e604ec27fb68162b7bf1c64980e90 |
File details
Details for the file scrapy_scraperapi_middleware-1.0-py3-none-any.whl
.
File metadata
- Download URL: scrapy_scraperapi_middleware-1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: 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.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ce7c245cca519dd2880d7b0292d8fe1341516a2765d88937477403da234d599 |
|
MD5 | cd222965f98e55f28542e3bf9815df4f |
|
BLAKE2b-256 | 861988b8438d092f63f31cfbe60e48c389a00980064c85d1b1704a820d03806f |