Live data from Hacker News

Convert Curl Syntax to Python Requests

curl.trillworks.com

1–10 of 47 posts

Re: Convert Curl Syntax to Python Requests

#3
I'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

#4
Failed 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

#6
post #2

I 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

#10
this 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
Post reply on HN