Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rubix982/31f3f255e788ae027b1f8ad1b647a35a to your computer and use it in GitHub Desktop.
Save Rubix982/31f3f255e788ae027b1f8ad1b647a35a to your computer and use it in GitHub Desktop.
Fetching images from the server
import os
import requests
from PIL import Image
from urllib.request import urlopen
all_images = []
os.makedirs('img')
for iter in image_id_list:
images = []
for index, image_url in enumerate(iter['thumb_2048_urls']):
data = Image.open(urlopen(image_url))
images.append(data)
with open(f'/content/img/{image_url[-50:]}.jpeg', 'wb') as f:
data.save(f)
all_images.append(images)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment