# copy images off of the web to your local machine
# (this should work for any files off the web...not just images)
import urllib
import os
url_of_file = "http://www.example.com/images/example_image.jpg"
local_file = "local_copy.jpg"
# retrieve from web and put in local_file
urllib.urlretrieve(url_of_file, local_file)
# now proof that the file was copied
# just listing all files in working directory
print os.listdir('.')
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Showing posts with label urlretrieve. Show all posts
Showing posts with label urlretrieve. Show all posts
Wednesday, September 23, 2009
python - copy images (or any file) from the web to local machine
Labels:
listdir,
os,
python,
urllib,
urlretrieve
Subscribe to:
Posts (Atom)