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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s