Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60698
| Date | 2013-11-28 15:19 +0000 |
|---|---|
| Subject | Downloading/Saving to a Directory |
| From | "TheRandomPast ." <wishingforsam@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3359.1385653859.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Downloading/Saving to a Directory "TheRandomPast ." <wishingforsam@gmail.com> - 2013-11-28 15:19 +0000
csiph-web