To make an HTTP request with a custom body as binary and return a binary response in Python, we can use the requests
library. Here's an example:
main.py333 chars15 lines
In the example above, we first import the requests
library. Then we set up the URL we want to make a request to and the binary data that we want to send as the request body. We use the requests.post()
method to send the HTTP POST
request to the URL with the binary data as the request body.
After we receive the response, we get the binary content of the response using the response.content
attribute. We can then do something with the response content as needed. In this example, we simply print it to the console.
gistlibby LogSnag