From 01a7c591adbfe68f75387d060d01c701b76d7afb Mon Sep 17 00:00:00 2001 From: akamhy <64683866+akamhy@users.noreply.github.com> Date: Thu, 7 May 2020 15:46:39 +0530 Subject: [PATCH] retry --- waybackpy/wrapper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/waybackpy/wrapper.py b/waybackpy/wrapper.py index 855692c..2bbe096 100644 --- a/waybackpy/wrapper.py +++ b/waybackpy/wrapper.py @@ -45,6 +45,11 @@ def save(url, UA=default_UA): raise UrlNotFound(e) else: raise PageNotSaved(e) + except URLError: + try: + response = urlopen(req) #nosec + except URLError as e: + raise UrlNotFound(e) header = response.headers if "exclusion.robots.policy" in str(header): @@ -59,8 +64,11 @@ def get(url, encoding=None, UA=default_UA): req = Request(clean_url(url), headers=hdr) #nosec try: resp=urlopen(req) #nosec - except URLError as e: - raise UrlNotFound(e) + except URLError: + try: + resp=urlopen(req) #nosec + except URLError as e: + raise UrlNotFound(e) if encoding is None: try: encoding= resp.headers['content-type'].split('charset=')[-1]