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}},
)
Metadata
Release files for scrapy-agentfive-middleware 0.0.2
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-agentfive-middleware-0.0.2.tar.gz | 3.4 kB | Without provenance | Details for scrapy-agentfive-middleware-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scrapy_agentfive_middleware-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for scrapy_agentfive_middleware-0.0.2-py3-none-any.whl |
Total release size: 8.1 kB
Release files / scrapy-agentfive-middleware-0.0.2.tar.gz
| Download URL | scrapy-agentfive-middleware-0.0.2.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a404b5dc153c976d23bbbe6bbae44d8b9e26dcbfa33e2bc187db922e5e0e208e
|
|
BLAKE2b-256 checksum How to use checksums |
a7dad2d21385e2dedec193f3445ab4696cf7d0de35e2005694f7573867fcfd93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / scrapy_agentfive_middleware-0.0.2-py3-none-any.whl
| Download URL | scrapy_agentfive_middleware-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5ef2f1905091b144c89a1d3f00422d92cf0f501b6c6be917bee6fdd77eaff2d
|
|
BLAKE2b-256 checksum How to use checksums |
36736ac83fb92d643f5deaf8f48e8bcd76567db1ef9f20b28f72afa18c6f40b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for scrapy-agentfive-middleware 0.0.2
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.