2 comments

[ 5.2 ms ] story [ 14.4 ms ] thread
Background: I wanted to use Python to automate some web requests, replicating some XHRs made by a site. Safari Web Inspector will show you the details of the request, and even lets you "Copy as cURL," but it was time consuming to write the corresponding Python code.

So I took the opportunity to learn a little bit of React, and wrote a simple tool to convert curl command line arguments to Python Requests. It covers only a small subset of curl options at this point, but the code should allow new ones to be added easily. The structure lets me to independently work on the parsing frontend or code generation backend, so I was able to easily add the ability to parse raw HTTP requests as well.

Someone pointed out that there is also the curl-to-Go tool which does the same thing for translating curl commands to Go code. https://mholt.github.io/curl-to-go/

Python request doesn't appear on iOS 10.2, only JSON works. Unfortunately I can't have a look on the console now...