Skip to content Skip to sidebar Skip to footer

Python Requests .iter_content() Generator To Binary Data?

I'm using the Python requests API to stream data over HTTP and need to decode the binary data properly. Each block of data starts with a one byte header ('H', 'N', or 'S') and the

Solution 1:

If you really really want to use iter_content you will need to buffer the data somewhere. You might find it easier just to use Response.raw, because despite what your original question states it absolutely can uncompress the data:

r = requests.get(url, stream=True)
data = r.raw.read(decode_content=True)

Post a Comment for "Python Requests .iter_content() Generator To Binary Data?"