Update wrapper.py
This commit is contained in:
parent
d5fb9a5219
commit
53561ec9c4
@ -30,9 +30,12 @@ class InvalidUrlError(Exception):
|
|||||||
Wayback machine respects these file, will not archive.
|
Wayback machine respects these file, will not archive.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def clean_url(url):
|
||||||
|
return str(url).strip().replace(" ","_")
|
||||||
|
|
||||||
def save(url,UA=default_UA):
|
def save(url,UA=default_UA):
|
||||||
base_save_url = "https://web.archive.org/save/"
|
base_save_url = "https://web.archive.org/save/"
|
||||||
request_url = base_save_url + url
|
request_url = base_save_url + clean_url(url)
|
||||||
hdr = { 'User-Agent' : '%s' % UA }
|
hdr = { 'User-Agent' : '%s' % UA }
|
||||||
req = Request(request_url, headers=hdr)
|
req = Request(request_url, headers=hdr)
|
||||||
if "." not in url:
|
if "." not in url:
|
||||||
@ -62,7 +65,7 @@ def near(
|
|||||||
UA=default_UA,
|
UA=default_UA,
|
||||||
):
|
):
|
||||||
timestamp = str(year)+str(month)+str(day)+str(hour)+str(minute)
|
timestamp = str(year)+str(month)+str(day)+str(hour)+str(minute)
|
||||||
request_url = "https://archive.org/wayback/available?url=%s×tamp=%s" % (str(url).strip(), str(timestamp))
|
request_url = "https://archive.org/wayback/available?url=%s×tamp=%s" % (clean_url(url), str(timestamp))
|
||||||
hdr = { 'User-Agent' : '%s' % UA }
|
hdr = { 'User-Agent' : '%s' % UA }
|
||||||
req = Request(request_url, headers=hdr)
|
req = Request(request_url, headers=hdr)
|
||||||
response = urlopen(req) #nosec
|
response = urlopen(req) #nosec
|
||||||
|
Loading…
Reference in New Issue
Block a user