Decompressing zipped Javascript

Because it took me soooo long to figure this out…

Zipped Javascript pulled from a URL using python requests; requests.get assigned to r.

#via https://stackoverflow.com/a/28642346/454773

import gzip
import base64

jsonTxt = gzip.decompress(base64.b64decode(r.text))

#using zlib.compress gives an error: lib.error:
#Error -3 while decompressing data: incorrect header check

Author: Tony Hirst

I'm a Senior Lecturer at The Open University, with an interest in #opendata policy and practice, as well as general web tinkering...

%d bloggers like this: