make a http request with a custom body as binary in python

You can make a HTTP request with a custom body as binary in Python using the requests library. Here's an example:

main.py
import requests

url = 'https://example.com'
data = b'\x01\x02\x03\x04'

response = requests.post(url, data=data)

print(response.text)
136 chars
9 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