If you want to download images from the internet, assuming that you already have the list of image urls, then the best way is using python.
Most of the articles on the internet provide a code to download images with a predefined image name, and do not allow to preserve the original image name. These codes do not allow the users to download large number of images as the images cannot be named dynamically.
One such example of the code snippet is mentioned below.
URl = http://ecx.images-amazon.com/images/I/41qJGxrMW0L._SL500_AA300_.jpg
In the above code, the image url is
The name of the image is
41qJGxrMW0L._SL500_AA300_.jpg which we are mainly interested in. In the above code, python will download the image from the
URL and will save the image with the name
If we have to download images from a list of image URLS then it is better to save the urls in a text file, with each URL starting on a new line. The text file should contain only URLS and nothing else (Not even empty lines), and consider the text file name to be
Your text file should look like this..
You can add as many URLS as you wish to this text file..Now create a folder and place the links.txt file and the python file (download_image.py) in this folder.
The python code for downloading the images will look something like this..
input_file = open('links.txt','r')
for line in input_file:
IMAGE = URL.rsplit('/',1)
Analysing the code:
import urllib: Import Library necessary to process URLS and download images.
input_file = open('links.txt','r'): This will open the URLS file containing the image urls.
for line in input_file:For each line in the txt file python will process the code below this line.
- URL = line : process each URL separately.
IMAGE = URL.rsplit('/',1): This is the instruction, which differentiates this code from other codes. It will strip the url so as to keep only the image name. After this instruction,
http://ecx.images-amazon.com/images/I/41qJGxrMW0L._SL500_AA300_.jpgwill change to
urllib.urlretrieve(URL, IMAGE): This will download the image from the url specified by variable URL and will name the image with the name specified IMAGE .
This is the easiest method I found to download images from the internet, without modifying the original image name. Let your views be reflected in the comments section below, and help to improve this code.Download Images from URLs using pythonhttp://www.gadgetcluster.com/2014/07/download-images-from-urls-using-python/http://i1.wp.com/www.gadgetcluster.com/wp-content/uploads/2014/07/py.png?fit=300%2C300http://i1.wp.com/www.gadgetcluster.com/wp-content/uploads/2014/07/py.png?resize=150%2C150 COMPUTER