Scrapy downloader middleware to interact with agentfive API
Project description
This package provides a Scrapy Downloader Middleware to interact with the agentfive API.
Requirements
- Python 3.5+
- Scrapy 1.6+
Installation
pip install scrapy-agentfive-middleware
Configuration
Enable the AgentfiveMiddleware via the
DOWNLOADER_MIDDLEWARES
setting:
DOWNLOADER_MIDDLEWARES = {
"agentfive_middleware.AgentfiveMiddleware": 585,
}
Please note that the middleware needs to be placed before the built-in HttpCompressionMiddleware
middleware (which has a priority of 590), otherwise incoming responses will be compressed and the
agentfive middleware won't be able to handle them.
Settings
-
AGENTFIVE_KEY(typestr)API key to be used to authenticate against the agentfive API.
-
AGENTFIVE_API_URL(Typestr, default"https://api.agentfive.cn/v1")The endpoint of a agentfive API.
-
AGENTFIVE_DEFAULT_ARGS(typedict, default{})Default values to be sent to the agentfive API. For instance, set to
{"profile": "mobile"}to set all requests with a mobile profile.
Usage
If the middleware is enabled, by default all requests will be redirected to the specified agentfive API endpoint, and append necessary params which agentfive API expected.
For example:
scrapy.Request(url="https://httpbin.org/anything")
will be set to agentfive API and let agentfive to fetch the url.
Additional arguments
Additional arguments could be specified under the agentfive Request.meta key. For instance:
Request(
url="https://example.org",
meta={"crawlera_fetch": {"render": True, "wait_ms": 5000}},
)
for more information on agentfive API parameter, please refer to agentfive document.
Skipping requests
You can instruct the middleware to skip a specific request by setting the agentfive.skip
Request.meta
key:
Request(
url="https://example.org",
meta={"agentfive": {"skip": True}},
)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scrapy-agentfive-middleware-0.0.2.tar.gz.
File metadata
- Download URL: scrapy-agentfive-middleware-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a404b5dc153c976d23bbbe6bbae44d8b9e26dcbfa33e2bc187db922e5e0e208e
|
|
| MD5 |
1e044ac3a3d89ec5ccd866460ba5708d
|
|
| BLAKE2b-256 |
a7dad2d21385e2dedec193f3445ab4696cf7d0de35e2005694f7573867fcfd93
|
File details
Details for the file scrapy_agentfive_middleware-0.0.2-py3-none-any.whl.
File metadata
- Download URL: scrapy_agentfive_middleware-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5ef2f1905091b144c89a1d3f00422d92cf0f501b6c6be917bee6fdd77eaff2d
|
|
| MD5 |
9722d117eb35db0d8361399e3e23b716
|
|
| BLAKE2b-256 |
36736ac83fb92d643f5deaf8f48e8bcd76567db1ef9f20b28f72afa18c6f40b2
|