A Library to Convert Curl to Python Requests File
Project description
curl2pyreqs
A library to convert curl to python requests file.
Requirement
Python >= 3.8
pyperclip >= 1.8.0
On Linux, xclip or xsel needed:
sudo apt-get install xclip
or
sudo apt-get install xsel
Install
$ pip install curl2pyreqs
Usage
Use as binary
- Export curl request file to python script.
$ curl2pyreqs -F example.curl
Convertion Finished.
Please open example.py to check the code.
- Convert curl request in the clipboard and paste the requests code back
$ curl2pyreqs
Convertion Finished.
Now requests code is copyed in your clipboard.
Use by importing
- Convert a curl string to python-requests, copyed from Chrome or Firefox:
>>> from curl2pyreqs import parseCurlString
>>> output = parseCurlString("""curl -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'accept-language: en-US,en;q=0.5' --compressed -H 'upgrade-insecure-requests: 1' -H 'te: trailers' https://pypi.org/""")
>>> print(output)
- Convert curl file stream to python-requests, copyed from Chrome or Firefox:
>>> from curl2pyreqs import parseCurlFile
>>> output = parseCurlFile('./example.curl')
>>> print(output)
README_CN
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
curl2pyreqs-0.1.1.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for curl2pyreqs-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f5002a8af15552320548034709e1b570ffebbd4ee34e0cc1698779dffc53ff7 |
|
MD5 | f1090a85555ede37efdfb1bb142dc419 |
|
BLAKE2b-256 | d7ab39ecc9d4588cb4671561ba935db6e25314fc9a14599f7b55076e3a11f7a0 |