i have specific requirement need download more 100 files website. wanted download these files file names not consecutive (e.g., www.blah.com/1 , www.blah.com/3, www.blah.com/4, www.blah.com/10). wanted go through sequence , skip if link unavailable. efficient way in python ?
assuming have normal tcp/ip connection follwoing code maybe of use
import urllib2 def download(link, filename): try: req=urllib2.urlopen(link) except urllib2.httperror: pass if req.has_data(): open(filename,"wb").write(req.get_data()) #here goes function loops on uri="http://example.com/" x in xrange(1, 101): download(uri+str(x), str(x)) just example. modify please
Comments
Post a Comment