Python 3.4 - Downloading Images
Programs do a lot of the work for you, or they should. It also shouldn't be work to get program to do all the work we don't want to do. Take for example this tutorial. If you want to download images from a site you don't have to do it one at a time. You can simply write a function to do it for you. Modules do most of the work for you.
This function would save whatever image you downloaded in the file directory for this file.
https://www.youtube.com/watch?v=GQiLweAoxgQ
This function would save whatever image you downloaded in the file directory for this file.
import urllib.request import random def downloader(image_url): file_name = random.randrange(1,10000) full_file_name = str(file_name) + '.jpg' urllib.request.urlretrieve(image_url,full_file_name) downloader(url)
https://www.youtube.com/watch?v=GQiLweAoxgQ
Comments