How can I programmatically convert urllib2.Request object into the equivalent curl command?
My Python script constructs several urllib2.Request objects, with different headers and postdata. For debugging purposes, I'd like to replay each request with curl. This seems tricky, as we must consider Bash escaping and urllib2's default headers. Is there a simple way to do this?
Simple way would be to run wireshark to capture the desired requests and then replay them with a packet replay tool like TCPreplay. If you do want to modify parts in curl for debugging wireshark will show you all the headers urllib2 is setting so you can set them the same in curl.
Translate a general urllib2.Request to curl command