<div dir="ltr">Hi, <div><br></div><div>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? </div>
<div><br></div><div>Just to clarify what I want to do is download all .jpg images on <a href="http://dogpicturesite.com">dogpicturesite.com</a> and save them to a directory on my computer. </div><div><br></div><div>Sorry if this is a really stupid question. </div>
<div><br></div><div><div>import traceback</div><div>import sys</div><div>from urllib import urlretrieve</div><div><br></div><div>try:</div><div><br></div><div> print ' imagefiles()'</div><div> images = re.findall(r'([-\w]+\.(?:jpg))', webpage)</div>
<div> urlretrieve('<a href="http://dogpicturesite.com/">http://dogpicturesite.com/</a>', 'C:/images)</div><div> print "Downloading Images....."</div><div> time.sleep(5)</div><div>
print "Images Downloaded."</div><div>except:</div><div> print "Failed to Download Images"</div><div> raw_input('Press Enter to exit...')</div><div> sys.exit()</div>
<div><br></div><div>def main():</div><div> sys.argv.append('<a href="http://dogpicturesite.com/">http://dogpicturesite.com/</a>')</div><div> if len(sys.argv) != 2:</div><div> print '[-] Image Files'</div>
<div> return</div><div> page = webpage.webpage(sys.argv[1])</div><div> imagefiles(webpage)</div></div><div><br></div><div><br></div></div>