Unable to decode response object
text = response.read()
if isinstance(text, bytes):
text = text.decode('utf-8')
text has this data in it, b'\x1f\x8b\x08\x00\x00'
0x1f 0x8b is the starting bytes for gzip files. .decode defaults to utf-8 which does not expect that start byte sequence - hence the invalid start byte message.
Try using the gzip module to decompress the file and then attempt to decode it (provided that the results are actually decodable). Example from the documentation, adapted for your case:
import gzip
data = gzip.decompress(response.read())
text = data.decode('utf-8')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With