HOME/Articles/

image downloader (snippet)

Article Outline

Python example 'image downloader'

Functions in program:

  • def download_image(url):

Modules used in program:

  • import urllib.request
  • import random

image downloader

Python beginners example: image downloader

import random
import urllib.request

get = str(input("Enter url of image to download :  "))

def download_image(url):
    name = random.randrange(1, 1000)
    full_name = str(name) + ".jpg"
    urllib.request.urlretrieve(url, full_name)

print(download_image(get))