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.13b0.tar.gz (9.5 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.13b0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for uncurlx-0.0.13b0.tar.gz
Algorithm Hash digest
SHA256 44d58a996fc239bffde0627e436736256ab78dfdb337aa915b8afd003a0b13a8
MD5 eb786f047693210d7b90786222754356
BLAKE2b-256 ea3dbfd5af431c4c2092f714dbdd390941959248deb68cdec615a225752435bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for uncurlx-0.0.13b0.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.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

Hashes for uncurlx-0.0.13b0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd97e87bac5b36908589941f31ebba0c1ae2af9af62f6d82d706e380156e49a1
MD5 89f53ad095353e0f0fcb8eb6c7cb2a1c
BLAKE2b-256 b74e93ec3fcceb2652515ce7a4d38068ba90c1a85c90666df345942692242c27

See more details on using hashes here.

Provenance

The following attestation bundles were made for uncurlx-0.0.13b0-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