scrapy-crawio
Scrapy downloader middleware for Crawio.
Your spiders make normal requests; this middleware routes them through the Crawio API, which fetches each one from a healthy exit — using the cheapest route that works, up to a full browser when the site's anti-bot needs one — and returns the site's own response. No spider changes, no per-request proxy juggling. Only successful requests are billed.
Install
pip install scrapy-crawio
Configure (settings.py)
DOWNLOADER_MIDDLEWARES = {
"scrapy_crawio.CrawioMiddleware": 1000,
}
CRAWIO_API_KEY = "rk-..." # required — dashboard -> API Key
CRAWIO_DOMAINS = ["example.com"] # hosts to route; omit to route every request
CRAWIO_API_URL = "https://api.crawio.com" # optional
CRAWIO_TIMEOUT = 120 # seconds, optional
CRAWIO_SESSION = "job-1" # optional: default sticky session id
# Recommended: let Scrapy retry the transient answers.
RETRY_ENABLED = True
RETRY_HTTP_CODES = [429, 502, 503, 504]
Use
Write spiders exactly as normal — the matched hosts go through Crawio:
import scrapy
class BooksSpider(scrapy.Spider):
name = "books"
def start_requests(self):
yield scrapy.Request("https://example.com/catalogue/page-1.html", callback=self.parse)
def parse(self, response):
self.logger.info("fetched in %s ms", response.headers.get("X-Crawio-Ms", b"").decode())
for href in response.css("h3 a::attr(href)").getall():
yield response.follow(href, callback=self.parse_item)
A page or JSON arrives as a TextResponse. A file (PDF, image, archive) arrives as a plain
scrapy.http.Response with its original bytes in response.body.
Response headers
Every response through Crawio carries these, alongside the site's own headers:
| Header | Meaning |
|---|---|
X-Crawio-Request-Id |
The request's reference (req_...). Quote it when you contact support. |
X-Crawio-Cost |
Credits this request used: 1, or 0 when it was not billed (blocks, errors, timeouts). |
X-Crawio-Ms |
Crawio's own time for the fetch, in milliseconds. |
Error responses (429, 502, 503, 504) carry X-Crawio-Request-Id and X-Crawio-Cost too, and a 429
carries Retry-After.
Per-request overrides
scrapy.Request(url, meta={"crawio_skip": True}) # download this one directly, not through us
scrapy.Request(url, meta={"crawio_session": "job-2"}) # pin to a sticky session
A sticky session keeps the same exit and the same cookies across requests: sign in once, reuse the id, and the following requests stay signed in.
Retries and billing
Every request carries an Idempotency-Key, so a retry reattaches to the same job instead of
starting — and billing — a second one. The key is stamped on the Request, so Scrapy's own
RetryMiddleware reuses it.
What Crawio answers
| code | meaning |
|---|---|
| 200 | success — the site's response is in the body |
| 401 | invalid API key; the request is dropped, not retried |
| 403 | account suspended; fix the account, do not retry |
| 410 | a strict sticky session lost its exit — sign in again on a new session |
| 429 | a plan limit: the body names which (rate_limited, concurrency_limit, daily_quota_exceeded, monthly_quota_exceeded, credits_used_up) and Retry-After says when, where the wait is known |
| 502 | the site blocked the request behind its anti-bot |
| 503 | no capacity right now; retry |
| 504 | the fetch timed out |
Everything except 401 comes back as a real Response, so RetryMiddleware decides what to do with
it and the body tells you why.
License
MIT
Metadata
Release files for scrapy-crawio 1.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_crawio-1.1.0.tar.gz | 6.8 kB | With provenance | Details for scrapy_crawio-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scrapy_crawio-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for scrapy_crawio-1.1.0-py3-none-any.whl |
Total release size: 14.2 kB
Release files / scrapy_crawio-1.1.0.tar.gz
| Download URL | scrapy_crawio-1.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5aa8019f5e8608e1fec9ed91eba4056a49ce7d230f8b4e39f2c473da5217e34a
|
|
BLAKE2b-256 checksum How to use checksums |
61e414d185662e71dda597ae72629f7ac28c9d077bca4746ab346e55d00a9b24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logRelease files / scrapy_crawio-1.1.0-py3-none-any.whl
| Download URL | scrapy_crawio-1.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c405993c30db683e7d53785242b9b5527bdf8e9ac65bbe302156cd142fff4d2c
|
|
BLAKE2b-256 checksum How to use checksums |
26cfcfe538539468b4fa5e77aeac53524b4ae0b7d7699df6de04165814cb0533
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logSecurity for scrapy-crawio 1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for scrapy_crawio-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 18, 2026.
Transparency logA 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.