curl_cffi’s documentation¶
Contents:
- Quick Start
- Impersonate Guide
- What is TLS and http/2, http/3 fingerprinting?
- Supported browser impersonate targets
- Which target version to use?
- How to use my own fingerprints? e.g. okhttp
- How to check if my impersonation is working?
- I’m still being detected even if I impersonated correctly
- Should I randomize my fingerprints for each request?
- Can I change JavaScript fingerprints with this library?
- Advanced Topics
- Compatibility with requests
- Cookies
- Community
- API References
- FAQ
- What does the pro version offer? Is the open source project still maintained?
- Why does the JA3 fingerprints change for Chrome 110+ impersonation?
- Can I bypass Cloudflare with this project? or any other specific site.
- I’m getting certs errors
- ErrCode: 77, Reason: error setting certificate verify locations
- How to use with fiddler/charles to intercept content
- ErrCode: 92, Reason: ‘HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)’
- Packaging with PyInstaller
- How to change the order of headers?
- How to deal with encoding/decoding errors?
- Change Log
- Development and contributing
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¶
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 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
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
asynciowith proxy rotation on each request.Supports http 2.0 & 3.0, which requests does not.
Supports websocket.
requests |
aiohttp |
httpx |
pycurl |
curl_cffi |
|
|---|---|---|---|---|---|
http2 |
❌ |
❌ |
✅ |
✅ |
✅ |
http3 |
❌ |
❌ |
❌ |
☑️ |
☑️ |
sync |
✅ |
❌ |
✅ |
✅ |
✅ |
async |
❌ |
✅ |
✅ |
❌ |
✅ |
websocket |
❌ |
✅ |
❌ |
❌ |
✅ |
fingerprints |
❌ |
❌ |
❌ |
❌ |
✅ |
speed |
🐇 |
🐇🐇 |
🐇 |
🐇🐇 |
🐇🐇 |
Notes:
For pycurl, you need a http/3 enabled libcurl to make it work, while curl_cffi packages libcurl-impersonate inside Python wheels.
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.