python download image

import urllib.request

image_url = 'https://bit.ly/2XuVzB4' #the image on the web
save_name = 'my_image.jpg' #local name to be saved
urllib.request.urlretrieve(image_url, save_name)

Here is what the above code is Doing:
1. We’re using urllib.request.urlretrieve to download the image from the web.
2. We’re passing in the image_url and save_name variables as the first and second arguments.
3. urllib.request.urlretrieve will download the image and save it to the local directory.