import wget pre = 'http://arxiv.org/pdf/' end = '.pdf' date = 1601 fix = 1000 while True: url = pre + str(date).zfill(4) + "." + str(fix).zfill(5) + end try: wget.download(url) except ValueError: print "does not exist" if fix < 1: date -= 1 fix = 99999 fix -= 1