Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

unsplash python

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 
Python :: remove vowels in a string python 
Python :: print list in one line python 
Python :: power in python 
Python :: read api from django 
Python :: pandas df exact equals 
Python :: check if all elements in list are equal 
Python :: openpyxl get value from readonly cell 
Python :: List comprehension if-else 
Python :: change python version in colab 
Python :: install scrapy on pycharm 
Python :: optimize images using pillow 
Python :: latest version of python 
Python :: box plot in seaborn 
Python :: comtypes python 
Python :: download pdf python 
Python :: django update field after save 
Python :: regularization pytorch 
Python :: find highest value in array python 
Python :: boxplot python 
Python :: wap in python to check a number is odd or even 
Python :: make gif from images in python 
Python :: python command line keyword arguments 
Python :: pandas knn imputer 
Python :: python max 
Python :: python find index of closest value in list 
Python :: dataframe multiindex 
Python :: pyqt setfocus 
Python :: how to serach for multiple attributes in xpath selenium python 
Python :: requirement.txt for python 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =