Downloading/Saving to a Directory
TheRandomPast .
wishingforsam at gmail.com
Thu Nov 28 10:19:48 EST 2013
Hi,
I've created a script that allows me to see how many images are on a
webpage and their URL however now I want to download all .jpg images from
this website and save them onto my computer. I've never done this before
and I've become a little confused as to where I should go next. Can some
kind person take a look at my code and tell me if I'm completely in the
wrong direction?
Just to clarify what I want to do is download all .jpg images on
dogpicturesite.com and save them to a directory on my computer.
Sorry if this is a really stupid question.
import traceback
import sys
from urllib import urlretrieve
try:
print ' imagefiles()'
images = re.findall(r'([-\w]+\.(?:jpg))', webpage)
urlretrieve('http://dogpicturesite.com/', 'C:/images)
print "Downloading Images....."
time.sleep(5)
print "Images Downloaded."
except:
print "Failed to Download Images"
raw_input('Press Enter to exit...')
sys.exit()
def main():
sys.argv.append('http://dogpicturesite.com/')
if len(sys.argv) != 2:
print '[-] Image Files'
return
page = webpage.webpage(sys.argv[1])
imagefiles(webpage)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131128/651181ad/attachment.html>
More information about the Python-list
mailing list