I'm just getting my feet on the ground with Python (maybe 3 days now). The only issue with teaching my self is that I have no one to critique my work.
Correct me if I'm wrong but I think my algorithm/method for solving this problem is quite promising; but, the code not so much.
The program basically strips a web-page and puts it in to the designated directory. My favorite part is the method for deciding the image's extensions :)
import os, re, urllib def Read(url): uopen = urllib.urlopen(url) uread = '' for line in uopen: uread += line return uread def Find(what, where): found = re.findall(what, where) match =  for i in found: i = i[9:-1] match.append(i) return match def Retrieve(urls, loc): loc = os.path.realpath(loc) os.system('mkdir ' + loc +'/picretrieved') loc += '/picretrieved' x = 0 exts = ['.jpeg', '.jpg', '.gif', '.png'] for url in urls: x += 1 for i in exts: ext = re.search(i, url) if ext != None: ext = ext.group() urllib.urlretrieve(url, loc + '/' + str(x) + ext) else: continue print 'Placed', str(x), 'pictures in:', loc def main(): url = raw_input('URL to PicRetrieve (google.com): ') url = 'http://' + url loc = raw_input('Location for PicRetrieve older ("." for here): ') html = Read(url) urls = Find('img src=".*?"', html) print urls Retrieve(urls, loc) if __name__ == '__main__': main()