Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'sys': 0.07; 'except:': 0.09; 'try:': 0.09; 'def': 0.12; 'question.': 0.14; 'direction?': 0.16; 'main():': 0.16; 'next.': 0.16; 'urllib': 0.16; '8bit%:5': 0.22; 'import': 0.22; 'print': 0.22; "i've": 0.25; 'script': 0.25; 'subject:/': 0.26; '8bit%:3': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'allows': 0.31; 'computer.': 0.33; 'skip:d 20': 0.34; 'created': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'done': 0.36; 'hi,': 0.36; 'should': 0.36; 'wrong': 0.37; 'skip:& 10': 0.38; '8bit%:4': 0.38; 'to:addr :python-list': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'tell': 0.60; 'save': 0.62; 'kind': 0.63; 'become': 0.64; 'webpage': 0.68; 'skip:r 30': 0.69; '"downloading': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Mj981Qix/RtGf6WOX4CIPJeAg2zEVEyvalevvmsr2Z4=; b=y+XOhAAKZyuzmgVJBbStznJy8XditYWrF3iwudkjT9ZKTzFXos4t22lpAGw+GTppJI Almiq6OhM0aRwQdL0V1KQPxIrzOjLxvjwm/FpXG0Kfg4HXH7BUqZ+QE1TLOmFcx9vJzv AjEseHaPLReaXr9EQDckl2BnJy5xJ0mrtCPxxiIpy9eQH5yGDzuqDJJgvr1Mkwq6Hu8r K47iqs2soxzXkUSwyLmugp9AJW4umP74jzEsL5eCA99y8464AL+pClzsNz8SDHLuGdV2 lOHK/kJ/r+oi7VUljPSgCVMQeh1mpgI12WG2CTMFm0FWQ+Ejb6jYhZFLkEDg0mnVSbNm wmCQ== MIME-Version: 1.0 X-Received: by 10.194.193.39 with SMTP id hl7mr62335wjc.91.1385651988141; Thu, 28 Nov 2013 07:19:48 -0800 (PST) Date: Thu, 28 Nov 2013 15:19:48 +0000 Subject: Downloading/Saving to a Directory From: "TheRandomPast ." To: python-list@python.org Content-Type: multipart/alternative; boundary=047d7bae4922891d1804ec3e3e1d X-Mailman-Approved-At: Thu, 28 Nov 2013 16:50:57 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385653859 news.xs4all.nl 15882 [2001:888:2000:d::a6]:47403 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60698 --047d7bae4922891d1804ec3e3e1d Content-Type: text/plain; charset=ISO-8859-1 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) --047d7bae4922891d1804ec3e3e1d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi,=A0

I've created a script that a= llows 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 conf= used as to where I should go next. Can some kind person take a look at my c= ode and tell me if I'm completely in the wrong direction?=A0

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.=A0

Sorry = if this is a really stupid question.=A0

import traceback
import sys
fr= om urllib import urlretrieve

try:

=A0 =A0 =A0 =A0 print ' imagefiles()'
=A0 =A0 = =A0 =A0 images =3D re.findall(r'([-\w]+\.(?:jpg))', webpage)
=A0 =A0 =A0 =A0 urlretrieve('http://dogpicturesite.com/', 'C:/images)
=A0 =A0 = =A0 =A0 print "Downloading Images....."
=A0 =A0 =A0 =A0= time.sleep(5)
=A0 =A0 =A0 =A0 print "Images Downloaded."
except:
=A0 =A0 =A0 =A0 print "Failed to Download Images"
=A0 =A0 =A0 =A0 raw_input('Press Enter to exit...')
=A0 = =A0 =A0 =A0 sys.exit()

def main():
=A0 =A0 sys.argv.append('http://dogpicturesite.com/')
=A0 =A0 if len(sys.argv) !=3D 2:
=A0 =A0 =A0 =A0 print = 9;[-] Image Files'
=A0 =A0 =A0 =A0 return
=A0 =A0 page =3D webpage.webpage(sys.= argv[1])
=A0 =A0 imagefiles(webpage)


--047d7bae4922891d1804ec3e3e1d--