CurlSession
pip install curl-session
Initialize from a curl command string and get equivalent requests.Session and httpx.Client objects with the same headers, cookies, proxies, TLS options, and redirect/http2 behavior.
Usage
from curl_session import CurlSession
curl = 'curl -H "Accept: application/json" -b "a=1; b=2" https://example.com/api'
cs = CurlSession(curl)
# httpx
with cs.get_httpx_client() as client:
r = client.get(cs._parsed.url) # provide a URL as in original curl if needed
print(r.text)
# requests
with cs.get_requests_session() as s:
r = s.get(cs._parsed.url)
print(r.text)
# run original curl
cp = cs.run()
print(cp.stdout)
MultiCurl Usage
Use MultiCurl to parse and execute multiple cURL commands from a string, with optional filtering and delays.
from curl_session import multi_curl
curl_commands = """
curl 'https://example.com/api1'
curl 'https://example.com/api2' -H 'Authorization: Bearer token'
"""
mc = multi_curl.MultiCurl(curl_commands)
results = mc.run(delay=1.0, url_filter='api1') # Run with 1s delay, filter by URL substring
for curl in results:
print(f"URL: {curl.url}, Status: {curl.status_code}, Response: {curl.response}")
Tests
- Install deps
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pytest -q
Build and Deploy to PyPI
run release.sh
Notes
- This is a pragmatic parser covering common curl flags for headers, cookies, data, proxies, TLS, auth, redirect, and http2 options.
- If
--cookieis a filename, it's ignored for safety. Provide explicit cookie strings instead. - Timeouts and other runtime-only flags are intentionally not persisted to the session defaults.
Metadata
Release files for curl-session 0.1.18
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 |
|---|---|---|---|---|
| curl_session-0.1.18.tar.gz | 12.2 kB | Without provenance | Details for curl_session-0.1.18.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| curl_session-0.1.18-py3-none-any.whl | Python 3 | none | any | Details for curl_session-0.1.18-py3-none-any.whl |
Total release size: 23.3 kB
Release files / curl_session-0.1.18.tar.gz
| Download URL | curl_session-0.1.18.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fa5e1982dd89e47bb1d5f9a7a37e48a912290e1d543e77936912603ec6fc78c
|
|
BLAKE2b-256 checksum How to use checksums |
cb1b3fe280436376e540a38b4354b2717af8597ff9489867d98976243142cf0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / curl_session-0.1.18-py3-none-any.whl
| Download URL | curl_session-0.1.18-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b50a89213256240471deaf2623a74ec726ea14960cbc24db87e74ffcf7e5bdab
|
|
BLAKE2b-256 checksum How to use checksums |
3d45c4b1433b9f0652b5cc390ef5a25424f6228ccc2ec35f33187d821be3be4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for curl-session 0.1.18
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.