Skip to content

Instantly share code, notes, and snippets.

@thisiskeanyvy
Created May 15, 2021 19:16
Show Gist options
  • Save thisiskeanyvy/49f261b3b6e93a707b848138b753b3f1 to your computer and use it in GitHub Desktop.
Save thisiskeanyvy/49f261b3b6e93a707b848138b753b3f1 to your computer and use it in GitHub Desktop.
Générateur d'images aléatoires, implémenté avec l'api unsplash
import random, os, urllib.request
nbdownload = 100 #nombre d'images à générer
def program():
init()
download()
def init():
print("""
Unsplash Download par Keany Vy KHUN
""")
def download():
for i in range(nbdownload):
if not os.path.exists("photos/"):
os.makedirs("photos/")
os.chmod("photos/", 0o0777)
num = i + 1
url = 'https://source.unsplash.com/random?art,street-art,urban,nature,wallpapers'
urllib.request.urlretrieve(url, 'photos/'+ str(num * random.randint(0, 54654658)) +'.jpg')
exit()
program()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment