I\'m trying to scrape a site whilst taking a screenshot of every page. So far, I have managed to piece together the following code:
import json
import base64
You are decoding from base64 twice:
png_bytes = base64.b64decode(response.data['png'])
imgdata = base64.b64decode(png_bytes)
Simply do:
def parse_result(self, response):
imgdata = base64.b64decode(response.data['png'])
filename = 'some_image.png'
with open(filename, 'wb') as f:
f.write(imgdata)