Skip to main content

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

PyPI - Status Python test Status Dependencies Status

GitHub License GitHub commit activity Format Badge

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uncurlx-0.0.13rc1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uncurlx-0.0.13rc1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file uncurlx-0.0.13rc1.tar.gz.

File metadata

  • Download URL: uncurlx-0.0.13rc1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for uncurlx-0.0.13rc1.tar.gz
Algorithm Hash digest
SHA256 1178f16f0d05baddd75e80121f8ed73bdd60017fc4b811646a1f2e189911b50f
MD5 7fafccfc32a981ad50ead58f081255c5
BLAKE2b-256 c23ea427001742131c657f77736eb69d4ddc435cd06adf74c55f6213dc159fb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for uncurlx-0.0.13rc1.tar.gz:

Publisher: python-publish.yml on whichoneiwonder/uncurl-x

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file uncurlx-0.0.13rc1-py3-none-any.whl.

File metadata

  • Download URL: uncurlx-0.0.13rc1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for uncurlx-0.0.13rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 e803c67f5233bd5920efe39f20b66d41b66ef917312a29ff0cb12622f07a7e4a
MD5 9607e4235f32887344548504e4584965
BLAKE2b-256 29c751957b477234d659caca904a41868e07d9198546902d00db53baf8a1a80d

See more details on using hashes here.

Provenance

The following attestation bundles were made for uncurlx-0.0.13rc1-py3-none-any.whl:

Publisher: python-publish.yml on whichoneiwonder/uncurl-x

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page