curl_cffi’s documentation

Contents:

Discuss on Telegram

curl_cffi is a Python binding for curl-impersonate fork via cffi. For commercial support, visit impersonate.pro.

Unlike other pure Python http clients like httpx or requests, curl_cffi can impersonate browsers’ TLS signatures or JA3 fingerprints. If you are blocked by some website for no obvious reason, you can give this package a try.

If you are looking for Python http3 clients, curl_cffi added http3 support since v0.11.

Sponsors

SerpAPI

SerpAPI

Scrape Google and other search engines from SerpApi’s fast, easy, and complete API. 0.66s average response time (≤ 0.5s for Ludicrous Speed Max accounts), 99.95% SLAs, pay for successful responses only.

Bypass Cloudflare with API

YesCaptcha

Yescaptcha is a proxy service that bypasses Cloudflare and uses the API interface to obtain verified cookies (e.g. cf_clearance). Click here to register.

Easy Captcha Bypass for Scraping

Capsolver

CapSolver is an AI-powered tool that easily bypasses Captchas, allowing uninterrupted access to public data. It supports a variety of Captchas and works seamlessly with curl_cffi, Puppeteer, Playwright, and more. Fast, reliable, and cost-effective. Plus, curl_cffi users can use the code “CURL” to get an extra 6% balance! and register here

You can also click here to buy me a coffee.

Features

  • Supports JA3/TLS and http2 fingerprints impersonation, including recent browsers and custom fingerprints.

  • Much faster than requests/httpx, on par with aiohttp/pycurl, see benchmarks.

  • Mimics requests API, no need to learn another one.

  • Pre-compiled, so you don’t have to compile on your machine.

  • Supports asyncio with proxy rotation on each request.

  • Supports http 2.0 & 3.0, which requests does not.

  • Supports websocket.

Feature matrix

requests

aiohttp

httpx

pycurl

curl_cffi

http2

http3

☑️

☑️

sync

async

websocket

fingerprints

speed

🐇

🐇🐇

🐇

🐇🐇

🐇🐇

Notes:

  1. For pycurl, you need a http/3 enabled libcurl to make it work, while curl_cffi packages libcurl-impersonate inside Python wheels.

  2. Since v0.11.0. However, only Linux and macOS are supported, Windows is not supported due to failed building of ngtcp2.

Install

pip install curl_cffi --upgrade

For more details, see install.

Documentation

You can first check out Quick Start. Then the Impersonate Guide.

For advanced topics, checkout Cookies, Asyncio and WebSockets.

You can also find common use cases in the examples directory.

Finally, if something is missing from the tutorial, you can always find them in the API References.

If you have any questions, be sure to check out the FAQ section before opening an issue.

Indices and tables