Skip to content

Instantly share code, notes, and snippets.

@StrikingLoo
Created August 27, 2018 23:42
Show Gist options
  • Select an option

  • Save StrikingLoo/5268541dbd29ce25b239cf80df90cae2 to your computer and use it in GitHub Desktop.

Select an option

Save StrikingLoo/5268541dbd29ce25b239cf80df90cae2 to your computer and use it in GitHub Desktop.
def ascii_encode(img_url):
return unicodedata.normalize('NFKD', img_url).encode('ascii','ignore')
def download_pictures(self, response):
image_urls = get_image_urls(response)
for img_url in image_urls:
self.index+=1
print(img_url)
ascii_url = ascii_encode(img_url)
img_data = requests.get(ascii_url).content
with open(str(self.index)+".jpg", 'w') as handler:
handler.write(img_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment