Python Forum

Full Version: Cant Download Images from Unsplash Website
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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:

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")
cross-posted at StackOverflow. https://stackoverflow.com/q/66101502/4046632
What exactly was not clear, when you were asked to let us know when you do cross-post on other sites?