python how to decode http response

The response is encoded with brotli compression. This compression method isn’t supported by the standard library. You can install a third party package from pypi to decompress it – a number of packages are available.

For example

$ pip install brotli
>>> import brotli
>>> decompressed = brotli.decompress(response.content)
>>> dict_ = json.loads(decompressed)

If you’d prefer to avoid installing a third party module, remove 'br' from the ‘accept-encoding’ header in the request:

'Accept-Encoding':'gzip, deflate, br' -> 'Accept-Encoding':'gzip, deflate'

Leave a Comment