Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

download unsplash images

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 :: series to dataframe 
Python :: intersection python dict 
Python :: how to set pandas dataframe as global 
Python :: how to add a linebreak in python 
Python :: axios django post data 
Python :: how to convert float to string in python 
Python :: divide all values in array python 
Python :: python obfuscator github 
Python :: readlines 
Python :: check datatype python 
Python :: pandas to python datetime 
Python :: request download file 
Python :: django login required 
Python :: django channel 
Python :: python variable scope 
Python :: python __lt__ 
Python :: python loop index and value 
Python :: how to numbered jupyter notebook 
Python :: edit models in django admin 
Python :: fast input python 
Python :: get first element of tuple python 
Python :: python to postgresql 
Python :: check if string match regex python 
Python :: rename colums dataframe pandas 
Python :: string python 
Python :: del list python 
Python :: py function 
Python :: pyqt set focus 
Python :: python condition question 
Python :: find index of element in array python 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =