Skip to main content

scrapy-curl-cffi

Scrapy integration with curl_cffi (curl-impersonate).

Installation

pip install scrapy-curl-cffi

Another option, to enable Scrapy's support for modern HTTP compression protocols:

pip install scrapy-curl-cffi[compression]

Configuration

Update your Scrapy project settings as follows:

DOWNLOAD_HANDLERS = {
    "http": "scrapy_curl_cffi.handlers.CurlCffiDownloadHandler",
    "https": "scrapy_curl_cffi.handlers.CurlCffiDownloadHandler",
}

DOWNLOADER_MIDDLEWARES = {
    "scrapy_curl_cffi.middlewares.CurlCffiMiddleware": 200,
    "scrapy_curl_cffi.middlewares.DefaultHeadersMiddleware": 400,
    "scrapy_curl_cffi.middlewares.UserAgentMiddleware": 500,
    "scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware": None,
    "scrapy.downloadermiddlewares.useragent.UserAgentMiddleware": None,
}

TWISTED_REACTOR = "twisted.internet.asyncioreactor.AsyncioSelectorReactor"

Usage

To download a scrapy.Request with curl_cffi, add the curl_cffi_options special key to the Request.meta attribute. The value should be a dict with any of the following options:

  • impersonate - which browser version to impersonate
  • ja3 - ja3 string to impersonate
  • akamai - akamai string to impersonate
  • extra_fp - extra fingerprints options, in complement to ja3 and akamai strings
  • default_headers - whether to set default browser headers when impersonating, defaults to True
  • verify - whether to verify https certs, defaults to the DOWNLOAD_VERIFY_CERTIFICATES setting
  • http_version - HTTP version to force, e.g. "v1", "v2" or "v3"; defaults to the CURL_CFFI_HTTP_VERSION setting

See the curl_cffi documentation for more info on these options.

Alternatively, you can use the curl_cffi_options spider attribute or the CURL_CFFI_OPTIONS setting to automatically assign the curl_cffi_options meta for all requests.

Example spider

class FingerprintsSpider(scrapy.Spider):
    name = "fingerprints"
    start_urls = ["https://tls.browserleaks.com/json"]
    curl_cffi_options = {"impersonate": "chrome"}

    def parse(self, response):
        yield response.json()

curl_cffi interop

scrapy-curl-cffi strives to adhere to established Scrapy conventions, ensuring that most Scrapy settings, spider attributes, request/response attributes and meta keys configure the crawler's behavior in an expected manner.

All curl_cffi downloads share one curl_cffi.AsyncSession, created lazily on the first curl_cffi download and reused for connection pooling. The following settings configure it:

  • CURL_CFFI_MAX_CLIENTS - hard limit on simultaneous curl_cffi connections, defaults to 10
  • DOWNLOAD_VERIFY_CERTIFICATES - whether to verify https certs, as in Scrapy itself
  • CURL_CFFI_HTTP_VERSION - HTTP version to force, e.g. "v1", "v2" or "v3"; unset lets curl_cffi (and browser impersonation) pick the version
  • DOWNLOAD_BIND_ADDRESS - local address to bind curl_cffi downloads to, as in Scrapy itself; the bindaddress request meta key overrides it
  • DOWNLOAD_TLS_MIN_VERSION / DOWNLOAD_TLS_MAX_VERSION - TLS version limits, as in Scrapy itself

Similar projects

Metadata

Release files for scrapy-curl-cffi 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapy-curl-cffi 0.4.1
File Size Uploaded Provenance Actions
scrapy_curl_cffi-0.4.1.tar.gz 7.0 kB With provenance Details for scrapy_curl_cffi-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scrapy-curl-cffi 0.4.1
File Interpreter ABI Platform Actions
scrapy_curl_cffi-0.4.1-py3-none-any.whl Python 3 none any Details for scrapy_curl_cffi-0.4.1-py3-none-any.whl

Total release size: 15.4 kB

Release files / scrapy_curl_cffi-0.4.1.tar.gz

Download URL scrapy_curl_cffi-0.4.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
774251f72215491f00e26f25a4b301b05c0732b72844fd9320ad82d998b36db9
BLAKE2b-256 checksum
How to use checksums
b4cf0f0548a155aaa55566076ad5435135f45e5bbe14352cf30ca9cea16c9e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 28, 2026.

Transparency log

Release files / scrapy_curl_cffi-0.4.1-py3-none-any.whl

Download URL scrapy_curl_cffi-0.4.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17be7800f284a5c32cd4d2d9c25c5293d90453430596b5cf37618bbc568235c9
BLAKE2b-256 checksum
How to use checksums
56ef4f037ed88dbae8b14471f25d3287c36832fad7a64a4be8ce3b95223bdf84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 28, 2026.

Transparency log

Security for scrapy-curl-cffi 0.4.1

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.

Select from 2 files

Attestation for scrapy_curl_cffi-0.4.1.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 Oct 28, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page