Request Curl
A user-friendly wrapper for pycurl that simplifies HTTP requests.
Installation
Use the package manager pip to install curlquest.
NOTE: You need Python and libcurl installed on your system to use or build pycurl. Some RPM distributions of curl/libcurl do not include everything necessary to build pycurl, in which case you need to install the developer specific RPM which is usually called curl-dev.
pip install curlquest
Quickstart
A curlquest session manages cookies, connection pooling, and configurations.
Basic Usage:
import curlquest
s = curlquest.Session()
s.get('https://httpbin.org/get') # returns <Response [200]>
s.request('GET', 'https://httpbin.org/get') # returns <Response [200]>
Using a Context Manager
import curlquest
with curlquest.Session() as session:
session.get('https://httpbin.org/get') # returns <Response [200]>
Features
Response Object
The response object is similar to that of the requests library.
import curlquest
s = curlquest.Session()
r = s.get("https://httpbin.org/get")
print(r) # prints response object
print(r.status_code) # prints status code
print(r.content) # prints response content in bytes
print(r.text) # prints response content as text
print(r.json) # prints response content as JSON
print(r.url) # prints response URL
print(r.headers) # prints response headers
Proxy Support
Format the proxy as a string.
import curlquest
s = curlquest.Session()
# supports authentication: r = s.get("https://httpbin.org/get", proxies="ip:port:user:password")
r = s.get("https://httpbin.org/get", proxies="ip:port")
HTTP2
HTTP2 is disabled by default.
import curlquest
s = curlquest.Session(http2=True)
r = s.get("https://httpbin.org/get")
Cipher Suites
You can specify custom cipher suites as an array.
import curlquest
cipher_suite = [
"AES128-SHA256",
"AES256-SHA256",
"AES128-GCM-SHA256",
"AES256-GCM-SHA384"
]
s = curlquest.Session(cipher_suite=cipher_suite)
r = s.get("https://httpbin.org/get")
Debug Request
Set debug to True to print raw input and output headers.
import curlquest
s = curlquest.Session()
r = s.get("https://httpbin.org/get", debug=True)
Custom Headers
Specify custom headers as a dictionary.
import curlquest
s = curlquest.Session()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"
}
r = s.get("https://httpbin.org/get", headers=headers)
Data
import curlquest
s = curlquest.Session()
# sending form data
form_data = {"key": "value"}
response = s.post("https://httpbin.org/post", data=form_data)
# sending json data
json_data = {"key": "value"}
response = s.post("https://httpbin.org/post", json=json_data)
Usage with Curl-Impersonate
To use curlquest with curl-impersonate, opt for our custom Docker image by either pulling or building it. The image comes with curlquest and curl-impersonate pre-installed. Check below for a demonstration on impersonating firefox98 tls-fingerprint and curlquest with our custom Docker Image.
Note: This feature is still considered experimental. Only tested with firefox fingerprint
To pull the Docker image:
docker pull h3adex/request-curl-impersonate:latest
docker run --rm -it h3adex/request-curl-impersonate
Example Python code for a target website:
import curlquest
from curlquest import FIREFOX98_CIPHER_SUITE, FIREFOX98_HEADERS
# impersonates ff98
session = curlquest.Session(
http2=True,
cipher_suite=FIREFOX98_CIPHER_SUITE,
headers=FIREFOX98_HEADERS
)
response = session.get("https://tls.browserleaks.com/json")
# <Response [200]>
# "ja3_hash":"25e9b0dd5b8e9330b206eae87e885e19"
# same result as:
# docker run --rm lwthiker/curl-impersonate:0.5-ff curl_ff98 https://tls.browserleaks.com/json
Contributing
We welcome contributions through pull requests. Before making major changes, please open an issue to discuss your intended changes. Also, ensure to update relevant tests.
License
Ennis Blank Ennis.Blank@fau.de, Mauritz Uphoff Mauritz.Uphoff@hs-osnabrueck.de
Metadata
Release files for curlquest 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| curlquest-0.1.1.tar.gz | 10.4 kB | Without provenance | Details for curlquest-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| curlquest-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for curlquest-0.1.1-py3-none-any.whl |
Total release size: 21.0 kB
Release files / curlquest-0.1.1.tar.gz
| Download URL | curlquest-0.1.1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99e91609795fa1b5d2b7c320a24e83943e0a7f26a73f7e6b2b98d749e48d0790
|
|
BLAKE2b-256 checksum How to use checksums |
6d14e1d8fa87a823ef7e0179618c625c10deb0a502919f5a2d29952bd5e0a4f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.8 Linux/6.8.1-arch1-1
|
Release files / curlquest-0.1.1-py3-none-any.whl
| Download URL | curlquest-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2d812d5ee600de1797341aac597521f41fc0e10a6abfbdd3e0a5de68b131641
|
|
BLAKE2b-256 checksum How to use checksums |
538d90ee4b9915342d03c310f1a92666d029ac7283f0a73b5802a222f7610fc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.8 Linux/6.8.1-arch1-1
|
Security for curlquest 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.