download image from url with python code example

Example 1: 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)

Example 2: python download image from url

import urllib.request
imgURL = "http://site.meishij.net/r/58/25/3568808/a3568808_142682562777944.jpg"

urllib.request.urlretrieve(imgURL, "D:/abc/image/local-filename.jpg")

Example 3: download image from url python 3

import urllib.request
urllib.request.urlretrieve(url, filename)

Tags:

Html Example