Update wrapper.py

This commit is contained in:
akamhy 2020-05-02 16:12:41 +05:30 committed by GitHub
parent 685fc730ed
commit 340475a411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,11 @@ def save(url,UA="pywayback python module"):
try: try:
response = urlopen(req) #nosec response = urlopen(req) #nosec
except urllib.error.HTTPError as e: except urllib.error.HTTPError as e:
if e.code == 502:
raise PageNotSavedError(e)
elif e.code == 429:
raise TooManyArchivingRequestsError(e) raise TooManyArchivingRequestsError(e)
header = response.headers header = response.headers
if "exclusion.robots.policy" in str(header): if "exclusion.robots.policy" in str(header):
raise ArchivingNotAllowed("Can not archive %s. Disabled by site owner." % (url)) raise ArchivingNotAllowed("Can not archive %s. Disabled by site owner." % (url))