Live data from Hacker News

Convert Curl Syntax to Python Requests

curl.trillworks.com

21–30 of 47 posts

Re: Convert Curl Syntax to Python Requests

#22
This is neat, but also seems like a code smell. Do people really need to convert between HTTP request formats/languages much? When I see many independent implementations of an N-to-M mapping, it looks like the perfect use case for a standardized interface, like a DSL.

In fact, can't HAR do this? I'd love to be able to just pass a HAR string to any HTTP client library, and have it execute that. Or call "dump_har()" (or "--dump-har") on any client, and have it spit out HAR that I can take it to any other client.

Re: Convert Curl Syntax to Python Requests

#26
post #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)

https://github.com/NickCarneiro/curlconverter/issues/new

Re: Convert Curl Syntax to Python Requests

#27
Author, here. curlconverter gets about 17k unique users per month. The code generated by this tool is probably in production all over the world.

But the codebase needs maintenance! I hired a junior developer (cf512) to do about 40 hours of dev work last month, but that contract has ended and I'd appreciate more volunteers. All the code is open source.

I see a few bug reports down thread. Please open tickets.

A big thanks to the top contributors, csells and jgroom33. Many others have pitched in over the last five years. Also, big thanks to Daniel Stenberg for writing curl in the first place.

Re: Convert Curl Syntax to Python Requests

#28
post #22

This is neat, but also seems like a code smell. Do people really need to convert between HTTP request formats/languages much? When I see many independent implementations of an N-to-M mapping, it looks like the perfect use case for a standardized interface, like a DSL. In fact, can't HAR do this? I'd love to be able to just pass a HAR string to any HTTP client library, and have it execute that. Or call "dump_har()" (o…

When reverse engineering or automating an API my workflow will often look like this:

1. Open browser inspector, watch API requests for one I'm interested in

2. Right click, "Copy as cURL"

3. Paste into a text editor, remove some unnecessary headers, re-running the curl command to verify that the headers I removed aren't important

4. Convert into python requests so that I can play with the parameters

Post reply on HN