retry
This commit is contained in:
parent
74d3bc154b
commit
01a7c591ad
@ -45,6 +45,11 @@ def save(url, UA=default_UA):
|
|||||||
raise UrlNotFound(e)
|
raise UrlNotFound(e)
|
||||||
else:
|
else:
|
||||||
raise PageNotSaved(e)
|
raise PageNotSaved(e)
|
||||||
|
except URLError:
|
||||||
|
try:
|
||||||
|
response = urlopen(req) #nosec
|
||||||
|
except URLError as e:
|
||||||
|
raise UrlNotFound(e)
|
||||||
|
|
||||||
header = response.headers
|
header = response.headers
|
||||||
if "exclusion.robots.policy" in str(header):
|
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
|
req = Request(clean_url(url), headers=hdr) #nosec
|
||||||
try:
|
try:
|
||||||
resp=urlopen(req) #nosec
|
resp=urlopen(req) #nosec
|
||||||
except URLError as e:
|
except URLError:
|
||||||
raise UrlNotFound(e)
|
try:
|
||||||
|
resp=urlopen(req) #nosec
|
||||||
|
except URLError as e:
|
||||||
|
raise UrlNotFound(e)
|
||||||
if encoding is None:
|
if encoding is None:
|
||||||
try:
|
try:
|
||||||
encoding= resp.headers['content-type'].split('charset=')[-1]
|
encoding= resp.headers['content-type'].split('charset=')[-1]
|
||||||
|
Loading…
Reference in New Issue
Block a user