Created
August 15, 2022 12:38
-
-
Save Rubix982/31f3f255e788ae027b1f8ad1b647a35a to your computer and use it in GitHub Desktop.
Fetching images from the server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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