Downloading/Saving to a Directory

T

TheRandomPast .

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top