# First import wget python module. import wget # Set up the image URL image_url = "https://i.pinimg.com/originals/c8/8d/a0/c88da00a9b617717204583a698c8afe9.jpg" # Use wget download method to download specified image url. image_filename = wget.download(image_url) print('Image Successfully Downloaded: ', image_filename)
# Importing required libraries import urllib.request # Adding information about user agent opener=urllib.request.build_opener() opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')] urllib.request.install_opener(opener) # setting filename and image URL filename = 'sunshine_dog.jpg' image_url = "https://i.pinimg.com/originals/c8/8d/a0/c88da00a9b617717204583a698c8afe9.jpg" # calling urlretrieve function to get resource urllib.request.urlretrieve(image_url, filename)