You can make a HTTP request with a custom body as binary in Python using the requests
library. Here's an example:
main.py136 chars9 lines
In this example, we're making a POST
request to https://example.com
with a custom binary body of \x01\x02\x03\x04
. The data
parameter is set to the binary data, prefixed with a b
. This tells Python that we're working with bytes rather than a string.
The requests.post()
function sends the HTTP request and returns a Response
object. We can access the response body using the text
property.
gistlibby LogSnag