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.13b1.tar.gz (9.6 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.13b1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uncurlx-0.0.13b1.tar.gz
  • Upload date:
  • Size: 9.6 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.13b1.tar.gz
Algorithm Hash digest
SHA256 d288f3a013deb3f8291112d4d9ae6847ea31c805e3040d5dd292f96abd8df8a6
MD5 94300c58c63a4c7cf55cfefa52d7c49f
BLAKE2b-256 16748c90da88cbdc49c50f29caff89b139d6017bfb95bbd43ac12f2a66fd0d1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for uncurlx-0.0.13b1.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.13b1-py3-none-any.whl.

File metadata

  • Download URL: uncurlx-0.0.13b1-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.13b1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f669a027836430839241aed17589ddc988e69568db77ccbce95c023db78277c
MD5 39d166207c9cc348ac06fcd6556adc8d
BLAKE2b-256 6563b6ce52c23dc1497b57a0348e5c50010075fcaf7be560f1cbc807f4a63cf0

See more details on using hashes here.

Provenance

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