Uncurl-X is a library that allows you to convert curl requests into python code that uses [httpx](https://www.python-httpx.org/).
Project description
Uncurl-X - Converting curl requests to python httpx requests
In a nutshell
Uncurl-X is a library that allows you to convert curl requests into python code that uses httpx. Since the Chrome network inspector has a nifty "Copy as cURL", this tool is useful for recreating browser requests in python.
When you don't pass any arguments to uncurlx, it will use whatever is in your clipboard as the curl command.
This is a fork of uncurl by spulec which converts from curl to requests.
Example
$ uncurl "curl 'https://pypi.python.org/pypi/uncurlx' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Cookie: foo=bar;' -H 'Connection: keep-alive' --compressed"
httpx.get("https://pypi.python.org/pypi/uncurlx", headers={
"Accept-Encoding": "gzip,deflate,sdch",
"Accept-Language": "en-US,en;q=0.8",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
}, cookies={
"foo": "bar",
})
The underlying API:
import uncurlx
print(uncurlx.parse("curl 'https://pypi.python.org/pypi/uncurlx' -H 'Accept-Encoding: gzip,deflate,sdch'"))
prints the string
'requests.get("https://pypi.python.org/pypi/uncurlx", headers={
"Accept-Encoding": "gzip,deflate,sdch",
})'
You can also retrieve the components as python objects:
>>> import uncurlx
>>> context = uncurl.parse_context("curl 'https://pypi.python.org/pypi/uncurlx' -H 'Accept-Encoding: gzip,deflate,sdch'")
>>> context.url
https://pypi.python.org/pypi/uncurlx
>>> context.headers
OrderedDict([('Accept-Encoding', 'gzip,deflate,sdch')])
On Mac OS, you can also pipe input to uncurlx:
pbpaste | uncurlx
Install
$ pip install uncurlx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uncurlx-0.0.13b0.tar.gz.
File metadata
- Download URL: uncurlx-0.0.13b0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44d58a996fc239bffde0627e436736256ab78dfdb337aa915b8afd003a0b13a8
|
|
| MD5 |
eb786f047693210d7b90786222754356
|
|
| BLAKE2b-256 |
ea3dbfd5af431c4c2092f714dbdd390941959248deb68cdec615a225752435bb
|
Provenance
The following attestation bundles were made for uncurlx-0.0.13b0.tar.gz:
Publisher:
python-publish.yml on whichoneiwonder/uncurl-x
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uncurlx-0.0.13b0.tar.gz -
Subject digest:
44d58a996fc239bffde0627e436736256ab78dfdb337aa915b8afd003a0b13a8 - Sigstore transparency entry: 192948953
- Sigstore integration time:
-
Permalink:
whichoneiwonder/uncurl-x@0faf141681a9fe9c0688199fc38591f5b7543d25 -
Branch / Tag:
refs/tags/0.0.13b0 - Owner: https://github.com/whichoneiwonder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0faf141681a9fe9c0688199fc38591f5b7543d25 -
Trigger Event:
release
-
Statement type:
File details
Details for the file uncurlx-0.0.13b0-py3-none-any.whl.
File metadata
- Download URL: uncurlx-0.0.13b0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd97e87bac5b36908589941f31ebba0c1ae2af9af62f6d82d706e380156e49a1
|
|
| MD5 |
89f53ad095353e0f0fcb8eb6c7cb2a1c
|
|
| BLAKE2b-256 |
b74e93ec3fcceb2652515ce7a4d38068ba90c1a85c90666df345942692242c27
|
Provenance
The following attestation bundles were made for uncurlx-0.0.13b0-py3-none-any.whl:
Publisher:
python-publish.yml on whichoneiwonder/uncurl-x
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uncurlx-0.0.13b0-py3-none-any.whl -
Subject digest:
dd97e87bac5b36908589941f31ebba0c1ae2af9af62f6d82d706e380156e49a1 - Sigstore transparency entry: 192948959
- Sigstore integration time:
-
Permalink:
whichoneiwonder/uncurl-x@0faf141681a9fe9c0688199fc38591f5b7543d25 -
Branch / Tag:
refs/tags/0.0.13b0 - Owner: https://github.com/whichoneiwonder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0faf141681a9fe9c0688199fc38591f5b7543d25 -
Trigger Event:
release
-
Statement type: