Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

download unsplash images code

import requests

# Download an image off unsplash without the api using python

def downloadimages(search_term, resolution, amount): # Define the function to download images
    print(f"https://source.unsplash.com/random/{resolution}/?"+str(search_term)+", allow_redirects=True") # State the URL
    
    for x in range(int(amount)):                                                                                                # Loop for chosen amount of times
        response = requests.get(f"https://source.unsplash.com/random/{resolution}/?"+str(search_term)+", allow_redirects=True") # Download the photo(s)
        print("Saving to: ./photos/" + str(search_term) + "_" + str(x + 1) + ".png")                                            # State the filename
        open("./photos/" + str(search_term) + "_" + str(x + 1) + ".png", 'wb').write(response.content)                          # Write image file


downloadimages("nature", "1080x1920", 15) # Call the Function
Comment

PREVIOUS NEXT
Code Example
Python :: download unsplash images python no api 
Python :: python convert bytes to string 
Python :: python access modifiers 
Python :: eval function in python 
Python :: how to change templates folder in flask 
Python :: initialize np array 
Python :: get mean using python 
Python :: python multithreading 
Python :: python garbaze collection 
Python :: python 3 tkinter treeview example 
Python :: how to make a comment in python 
Python :: xml depth python 
Python :: django login 
Python :: to_frame python 
Python :: Python program to find N largest elements from a list 
Python :: how to access items in a list 
Python :: python get first occurrence in list 
Python :: how to use django-rest-framework-datatables 
Python :: read a csv file in pandas 
Python :: django change settings at runtime 
Python :: add gaussian noise python 
Python :: pandas dataframe row names 
Python :: python for unity 
Python :: EOFError: EOF when reading a line 
Python :: how to make a timer using python 
Python :: convert dictionary keys to list python 
Python :: py one line function 
Python :: qt setfocus 
Python :: enumerate in django templte 
Python :: Using Lists as Queues 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =