Feb-08-2021, 02:36 PM
(This post was last modified: Feb-08-2021, 02:36 PM by firaki12345.)
Good Evening Everyone
So I am trying to download all wallpaper images from unsplash, got their API link from the network tab in Firefox. (It loads only 30 links per page which is fine)
EDIT: now I Am getting 30 SAME Images but with different names in my folder. Can Anyone Please Help :)
Here is the API link from network Tab: unsplash API link Network
Here is my Code:
So I am trying to download all wallpaper images from unsplash, got their API link from the network tab in Firefox. (It loads only 30 links per page which is fine)
EDIT: now I Am getting 30 SAME Images but with different names in my folder. Can Anyone Please Help :)
Here is the API link from network Tab: unsplash API link Network
Here is my Code:
import json
import pandas as pd
import requests
import time
with open ("Unsplash.json",encoding="UTF-8") as f:
s = json.load(f)
U = pd.json_normalize(s)
U.rename(columns={'alt_description':'Name','urls.raw':'Links'},inplace=True)
Links = U["Links"].tolist()
Name = U["Name"].tolist()
t1 = time.perf_counter()
# 1. Works Fine
for Index,l in enumerate(img_url,start = 1):
data = requests.get(img_url).content
with open ("Unsplash_Pics//" + str(Index) + ".jpg","wb") as f:
f.write(data)
# 2. i get SAME image 29 times but with different names :(
for l in Links:
data = requests.get(l).content
for name in Name:
with open ("Unsplash_Pics//" + str(name) + ".jpg","wb") as f:
f.write(data)
t2 = time.perf_counter()
print(f"Finishes in {t2-t1} Seconds")
