Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

download unsplash images script

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

Unsplash Image

unsplash.photos.getPhoto("pFqrYbhIAXs");
Comment

PREVIOUS NEXT
Code Example
Python :: download unsplash images python without api 
Python :: how to remove element from list python by index 
Python :: python remove by index 
Python :: how to change int to string in python 
Python :: django forms date picker 
Python :: python check if object is empty 
Python :: Python program to find uncommon words from two Strings 
Python :: python generator expression 
Python :: python region 
Python :: beautifulsoup 
Python :: python . 
Python :: add horizontal line to plotly scatter 
Python :: if statement in python 
Python :: Box Plot, Python 
Python :: channel hide command in discord.py 
Python :: Set value of dataframe using condition 
Python :: send dm to user discord.py 
Python :: chi square test contingency table python 
Python :: how to find and remove certain characters from text string in python 
Python :: check if item exists in list python 
Python :: dict map() 
Python :: tkinter simple application 
Python :: dict get value by index 
Python :: #remove a sublist from a list-use remove method 
Python :: python keyboard 
Python :: what are args and kwargs in python 
Python :: python single line function 
Python :: qt set focus 
Python :: pandas sub columns 
Python :: python list as queue 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =