Convert curl to python3 script. Either specify your input file which contains the curl script or copy the script to clipboard then run the program.
$ go install .
$ curl2py -h
Usage of curl2py:
-debug
Debug
-input string
Input File
E.g.,
curl 'http://localhost/ping' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'Accept-Language: en,zh-CN;q=0.9,zh;q=0.8' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-H 'Sec-Fetch-Dest: document' \
-H 'Sec-Fetch-Mode: navigate' \
-H 'Sec-Fetch-Site: none' \
-H 'Sec-Fetch-User: ?1' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"'
Code generated by curl2py
:
import requests
data = None
headers = {"Accept-Language":"en,zh-CN;q=0.9,zh;q=0.8","Sec-Fetch-Site":"none","Sec-Fetch-User":"?1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36","sec-ch-ua":"\"Chromium\";v=\"128\", \"Not;A=Brand\";v=\"24\", \"Google Chrome\";v=\"128\"","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","Cache-Control":"no-cache","Connection":"keep-alive","Pragma":"no-cache","Sec-Fetch-Dest":"document","sec-ch-ua-mobile":"?0","Sec-Fetch-Mode":"navigate","Upgrade-Insecure-Requests":"1","sec-ch-ua-platform":"\"macOS\""}
res = requests.get(url='http://localhost/ping', data=data, headers=headers)
print(res.status_code)
print(res.text)