curl_cffi
Python binding for curl-impersonate via CFFI.
Unlike other pure python http clients like httpx or requests, this package 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.
Install
pip install --upgrade curl_cffi
This should work for most Linux systems. If it does not work, you may need to compile and install curl-impersonate first.
Usage
requests/httpx-like API:
from curl_cffi import requests
# Notice the impersonate parameter
r = requests.get("https://tls.browserleaks.com/json", impersonate="chrome101")
print(r.json())
# output: {'ja3_hash': '53ff64ddf993ca882b70e1c82af5da49'
# the fingerprint should be the same as target browser
Or, the low-level curl-like API:
from curl_cffi import Curl, CurlOpt
from io import BytesIO
buffer = BytesIO()
c = Curl()
c.setopt(CurlOpt.URL, b'https://tls.browserleaks.com/json')
c.setopt(CurlOpt.WRITEDATA, buffer)
c.impersonate("chrome101")
c.perform()
c.close()
body = buffer.getvalue()
print(body.decode())
See example.py or tests/ from more examples.
API
Requests: almost the same as requests.
Curl object:
setopt(CurlOpt, value): Sets curl options as incurl_easy_setoptperform(): Performs curl request, as incurl_easy_performgetinfo(CurlInfo): Gets information in response after curl perform, as incurl_easy_getinfoclose(): Closes and cleans up the curl object, as incurl_easy_cleanup
Enum values to be used with setopt and getinfo can be accessed from CurlOpt and CurlInfo.
Current Status
This repo is very early stage for now, the pypi package only works on Linux, not macOS or Windows. If you wish to use it on macOS or Windows, you need to clone it and the curl-impersonate repo, and then compile them by yourself.
When people installing other python curl bindings, like pycurl, they often face
compiling issues or OpenSSL issues, so I really hope that this package can be distributed
as a compiled binary package, uses would be able to use it by a simple pip install, no
more compile errors.
For now, I just download the pre-compiled libcurl-impersonate from github and build a
bdist wheel, which is a binary package format used by PyPI, and upload it. However, the
right way is to download curl and curl-impersonate sources on our side and compile them
all together.
Help wanted!
TODOs:
- write docs.
- binary package for macOS and Windows.
- Support musllinux(alpine) bdist by building curl-impersonate from source.
- Update curl header files and constants via scripts.
- Implement
requests.Session/httpx.Session.
Acknowledgement
This package was originally forked from https://github.com/multippt/python_curl_cffi
Metadata
Release files for curl-cffi 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| curl_cffi-0.2.1.tar.gz | 69.8 kB | Details |
Built distributions (wheels)
Total release size: 146.4 MB
Release files / curl_cffi-0.2.1.tar.gz
| Download URL | curl_cffi-0.2.1.tar.gz |
|---|---|
| Size | 69.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c0f7ed67d32340b642f6bebc01e9963e0ec80f69b07b7100395bf7abb21a6dc
|
|
BLAKE2b-256 checksum How to use checksums |
01de1aafe4472cd2bec70eb15df1313f0b3d070f385884bec980346a4b11f95e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.1 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
1ce9a53e01e2d6259c10fe4fb5e86b4330b837cde24f3edc550c4b8dc00c2ca4
|
|
BLAKE2b-256 checksum How to use checksums |
f0a995b2a1695f215ef55009334d505f7667905f15ff04a018d0b9dbb4a735a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.9 PyPy 3.9 7.3 |
|
SHA-256 checksum How to use checksums |
eaf2a338f1908c386e50c813a68450eb1c568ea4e9c245c0207f58072827ccf6
|
|
BLAKE2b-256 checksum How to use checksums |
d46b65122ab893ea2be8f5157da75f4fc4a790ae32c0d7d729d7eb9da7c6bd17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | PyPy 3.9 PyPy 3.9 7.3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
bae6a6e774bf4dd9194f16c91932c209c90f9a5dedac9a90febbab4020f3ef93
|
|
BLAKE2b-256 checksum How to use checksums |
86f900cb8a53da35df2a260293e214d975b5e1e45c598755aec4e2405088bd04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.1 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
fb57f4f5b5018ecc95387f25e35d6b479b98c3a6e03220ff2f1c011527d16443
|
|
BLAKE2b-256 checksum How to use checksums |
2810e87e50c4fcd402bd637ef9d5d2840ad1606ee6913c3fcf6bbdb0357b91d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.8 PyPy 3.8 7.3 |
|
SHA-256 checksum How to use checksums |
d2a86ac1edf1affd77c1845c28c56784fa29da49995b76d51152cfa8a6a96d46
|
|
BLAKE2b-256 checksum How to use checksums |
ff53cf3b2b6451151fb7c59cc52a13cfc8e0f7aea9049c43e03c8f2a094b0333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | PyPy 3.8 PyPy 3.8 7.3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
c3725bba7ede60b73a452716a4774407711bb78fa1bcd3570db5e82a108c2fff
|
|
BLAKE2b-256 checksum How to use checksums |
ea9b9461968b00ffac26f8c574570733590b6bc19f55bf03428822f335be4fac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.1 MB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.7 PyPy 3.7 7.3 |
|
SHA-256 checksum How to use checksums |
ab5d707cb320c0456e9a5daabd6ed83d218b2a76c404021ac2bfded9aac85ce9
|
|
BLAKE2b-256 checksum How to use checksums |
516ef686a726ac4d7ac5136a951e5463897dc462d3423c1eb6822cab81ccc164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | Linux glibc 2.17+ ARM64 PyPy 3.7 PyPy 3.7 7.3 |
|
SHA-256 checksum How to use checksums |
9bd654433c6bd528529164a3b0eb9030e4d486e554c476e7ca69f27ca5966e1b
|
|
BLAKE2b-256 checksum How to use checksums |
04481a89b91984aac11ab9b5e8ea8509941cda89b6fd1a2945dc290ebac421a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | PyPy 3.7 PyPy 3.7 7.3 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
815abe41f42197d44eed305947aa87a1557d0df61ed13703cf196230a9c2048c
|
|
BLAKE2b-256 checksum How to use checksums |
94b8670460e85d7ff9743e38263a9056c940827180f30b8ee51aa5536410e828
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
da571737df089bc0145da6d7eb2f39eba4c5ed6170508f2836c718c00142cdba
|
|
BLAKE2b-256 checksum How to use checksums |
645fc5682d2143055b44ce99df696033961c44569c7fdbe06609692d0ee9de3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
2fd7a57945d3998d74155b1e559106463ec263aebdb8adeeebd274c9aa689096
|
|
BLAKE2b-256 checksum How to use checksums |
75e649b8b1f773aef5cf0ae3e588c844ed69adf7fc560b2d16ad359b5ef7571e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
11a893b974ba0f34325a45350974a63521b5f2e9c6778df9470c9851b28f1c1c
|
|
BLAKE2b-256 checksum How to use checksums |
9a23e717d2bb196c19325f6e4b7d8cb2943bb8ae6688fae8cce4f283e0a56ff4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
71895294f7e83f253f918c7c5defdcfb406af422bc93c930481bc50080936edf
|
|
BLAKE2b-256 checksum How to use checksums |
9c1bd5388d7cde5bc927fec4a21c23184c81217dcaef153691da73c18e4e9e39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
9d0be495b0023c965f957f7a8e9b0ccca131942065ef4ef46c0857cc92bf8666
|
|
BLAKE2b-256 checksum How to use checksums |
281b3a755ed13d5d35b2a8922e7c6780a1f7ceafa1b9bd037f3b1baf04780e62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
a8bd104cd32180ee5c06f2abd53a83095439b31018382bf7b4e76054db359c35
|
|
BLAKE2b-256 checksum How to use checksums |
0b25b70de1f65b2134bd53cd486de8cc484149f5c3d80ee3cdab6169bd3f8ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
24a12231f5711fc9a1372b34a6c3eade765e725551ca0f93d94f63ed0454e855
|
|
BLAKE2b-256 checksum How to use checksums |
f5e8468ebb73ebae5b29df80fb12fa8e2b0c5e73e0f716b9fa3d26ec26413227
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
08a9b634c869727dfe68c7994d516dab0300f1d9d6ac140579df6474f688d38c
|
|
BLAKE2b-256 checksum How to use checksums |
c964dd9ad809b1e6d7a80360861ed892c0b1d9e944e8d100f24a7c4f0d9f0dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp39-cp39-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.9 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
9e98f8ed5232580018376fba818a35256fe961a1353c3154de5e791139513286
|
|
BLAKE2b-256 checksum How to use checksums |
5f77a5f53f78458bf4f7d1cb8ddb524b2297f09c7555424f995753f0ff6f9889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ec295c1e32d5cdb83db4da6971b2f558b465bf0d865a100f87d8c9427ebcbac5
|
|
BLAKE2b-256 checksum How to use checksums |
0b52c7dcd54f83e2a16ba4f2037ac7e103569c176f4c960e13421302963705f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
c79ecb8812404239986a7cde385dd992f5dea28551b8e02aef5bd2081f361048
|
|
BLAKE2b-256 checksum How to use checksums |
5fcbb56b28ecbf5089d6bc7b802a26bc4538037c0d17942a54d7d6cce67a3f23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp38-cp38-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.8 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
ec65d0622d4ad9978521b919b27561f9b0d85e91dd8da0939d33f003509f7590
|
|
BLAKE2b-256 checksum How to use checksums |
583e4693d9ed0207617903232b05482085e37b6705c828b75e224ea6b5fe65ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bb14012d6579306287ffa2df690282b29e6f3943c4f5f2255ab13c63e33ab1ee
|
|
BLAKE2b-256 checksum How to use checksums |
f80a5c5cb7b1137cd3fe6bd4e21919bd9f7e3f0a80ec8511040d1fc1f5315cf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | curl_cffi-0.2.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.9 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
5e8b5f411c34304f39ad8fab593af06adf5ff7eddd8eae423cec7da1b6496476
|
|
BLAKE2b-256 checksum How to use checksums |
f0baf1d65c94cb209ca66f7c6ad39bc78b8815688cc0661ea2ac9c022859219f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / curl_cffi-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | curl_cffi-0.2.1-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
7858b04108ff1a5c6108a3077b7ac3844ddba8e98707073090ac7dddb469a749
|
|
BLAKE2b-256 checksum How to use checksums |
37f7ad7c80495abbfd23e4ac4d19a0180f2b64af584ac0b5c7da570c6b0e482b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|