Python Forum
Cant Download Images from Unsplash Website
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant Download Images from Unsplash Website
#1
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")
Reply
#2
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?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Website scrapping and download santoshrane 3 4,257 Apr-14-2021, 07:22 AM
Last Post: kashcode
  Login and download an exported csv file within a ribbon/button in a website Alekhya 0 2,617 Feb-26-2021, 04:15 PM
Last Post: Alekhya
  display local images on django website mp3909 2 6,247 Apr-01-2020, 11:18 AM
Last Post: mp3909
  download pdf file from website m_annur2001 1 2,956 Jun-21-2019, 05:03 AM
Last Post: j.crater
  Download images generated by user input one_of_us 0 2,465 Mar-26-2019, 07:58 AM
Last Post: one_of_us
  I wan't to Download all .zip Files From A Website (Project AI) eddywinch82 68 37,469 Oct-28-2018, 02:13 PM
Last Post: eddywinch82
  Download all secret links from a map design website fyec 0 2,813 Jul-24-2018, 09:08 PM
Last Post: fyec

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020