fix issue with py2.7
This commit is contained in:
parent
a8e94dfb25
commit
74d3bc154b
@ -112,6 +112,11 @@ def total_archives(url, UA=default_UA):
|
|||||||
hdr = { 'User-Agent' : '%s' % UA }
|
hdr = { 'User-Agent' : '%s' % UA }
|
||||||
request_url = "https://web.archive.org/cdx/search/cdx?url=%s&output=json" % clean_url(url)
|
request_url = "https://web.archive.org/cdx/search/cdx?url=%s&output=json" % clean_url(url)
|
||||||
req = Request(request_url, headers=hdr) # nosec
|
req = Request(request_url, headers=hdr) # nosec
|
||||||
with urlopen(req) as response: # nosec
|
try:
|
||||||
data = json.loads(response.read())
|
response = urlopen(req) #nosec
|
||||||
return (len(data))
|
except HTTPError as e:
|
||||||
|
if e.code == 502:
|
||||||
|
raise BadGateWay(e)
|
||||||
|
elif e.code == 503:
|
||||||
|
raise WaybackUnavailable(e)
|
||||||
|
return (len(json.loads(response.read())))
|
||||||
|
Loading…
Reference in New Issue
Block a user