Convert Curl Syntax to Python Requests
curl.trillworks.com
Convert Curl Syntax to Python Requests
1–10 of 47 posts
Re: Convert Curl Syntax to Python Requests
#2I feel like going the other way would be more useful.
Re: Convert Curl Syntax to Python Requests
#3I'm not the author of this tool, but I submitted it to HN because I just stumbled upon it after unsuccessfully trying to transpose a complicated cURL from Chrome devtools into python requests for a good 20 min. This worked instantly. Props to the author - https://twitter.com/nickc_dev
Re: Convert Curl Syntax to Python Requests
#4Failed entirely to work on my first attempt with:
curl -XHEAD https://google.com
It is just flat out wrong on: curl -X HEAD https://google.com
In that it does a GET request: import requests
response = requests.get('https://google.com/')
Clever idea, but my first totally valid example failed (it does OPTIONS, GET, POST, PUT, PATCH successfully)Re: Convert Curl Syntax to Python Requests
#5The "uncurl" library[1] does something similar and can be used in the terminal. I've found it extremely useful.
Re: Convert Curl Syntax to Python Requests
#6I feel like going the other way would be more useful.
I thought the same thing at first, but the site actually gives an indication of why this would be useful. The developer tools in at least some browsers can export a request as a curl command. So I can thus easily get the code to reproduce any request I see in my browser. That would have been useful a few times in the past, and more useful than the inverse.
Re: Convert Curl Syntax to Python Requests
#7Paw, which many people love, has a neat and similar feature: you can get extensions that convert the request you build in the app to any format: curl, python, etc.
It's very handy.
Re: Convert Curl Syntax to Python Requests
#8Here is a similar site that translates curl to Go:
Re: Convert Curl Syntax to Python Requests
#9Postman also has the ability to import a curl command (from chrome dev tool) and then export to many programming languages.
Re: Convert Curl Syntax to Python Requests
#10this is one of the most useful little tools on good's green earth. I used to work for a scraping company and I used it all day every day - load a page with inspector open, find your request, right click copy as curl, paste into trillworks and boom you have the request you want to automate (modulo fiddling with cookies). A+ bang/line of code