As a follow-up on Still looking for base64url decoding tools, both on-line and for MacOS homebrew: this is in Python, works on MacOS, Linux and Windows, and can be integrated in a web page.
It is based on the ideas in [WayBack] Python-Twitter-Hacks/websiteScreenshot.py at master · edent/Python-Twitter-Hacks · GitHub, which was more like a code snippet with hard coded literals.
It downloads a jpeg web-site screenshot using the Google PageSpeed API V1, which generates the screenshot as a base64url
encoded blob inside a JSON structure.
Python does not have native Python base64url support, but the concept of it is fairly straightforward: [WayBack] RFC 4648 – The Base16, Base32, and Base64 Data Encodings: Base 64 Encoding with URL and Filename Safe Alphabet, which allows data to be passed inside URLs without reverting to [WayBack] Percent-encoding – Wikipedia.
My changes work, but are by no means in canonical form or Idiomatic Python. I have a long way to go to reach that level of Python.
So I forked the repository, and fixed the script basing it on Python 3.
I might make it V2 compatible in the future. More information on V2 in [WayBack] Google APIs Explorer: Services > PageSpeed Insights API v2 > pagespeedonline.pagespeedapi.runpagespeed
- The V1 mobile URL is [Archive.is] https://www.googleapis.com/pagespeedonline/v1/runPagespeed?screenshot=true&strategy=mobile&url=https://mobile.twitter.com/matthaig1/status/1096700147474620416 ;
- V1 Desktop URL is [Archive.is] https://www.googleapis.com/pagespeedonline/v1/runPagespeed?screenshot=true&url=https://mobile.twitter.com/matthaig1/status/1096700147474620416
Content is in the below gist.
–jeroen