Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import urllib.error
- import random
- import http.client
- print('Beginning file download attempts...')
- var = 1
- while var == 1:
- try:
- number = (random.randint(22000000,24000000))
- code = (random.randint(101000,199999))
- url = 'http://www.ugrad.math.ubc.ca/coursedoc/math103/2017W2/quiz/quiz1/quiz1-%s-%s.pdf' % (number, code)
- urllib.request.urlretrieve(url, '/Users/alirod/Desktop/Python/examen/examen.pdf')
- except urllib.error.HTTPError as e:
- if e.code in (..., 403, ...):
- # print ('===HTTP Error 403===')
- print (number)
- print (code)
- continue
- except http.client.HTTPException as e:
- print ('HTTP Client Error')
- continue
- print ("End of Loop")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement