api changed; fix archive url parser
This commit is contained in:
@@ -73,16 +73,14 @@ class Url():
|
|||||||
raise WaybackError(e)
|
raise WaybackError(e)
|
||||||
header = response.headers
|
header = response.headers
|
||||||
|
|
||||||
try:
|
def archive_url_parser(header):
|
||||||
arch = re.search(r"rel=\"memento.*?web\.archive\.org(/web/[0-9]{14}/.*?)>", str(header))
|
arch = re.search(r"X-Cache-Key:\shttps(.*)[A-Z]{2}", str(header))
|
||||||
if arch:
|
if arch:
|
||||||
arch = arch.group(1)
|
return arch.group(1)
|
||||||
else:
|
else:
|
||||||
raise WaybackError("Can't create a new archive. No archive url found in reply headers.")
|
raise WaybackError("No archive url found in the reply headers. Visit https://github.com/akamhy/waybackpy for latest version of waybackpy.")
|
||||||
except KeyError as e:
|
|
||||||
raise WaybackError(e)
|
|
||||||
|
|
||||||
return "https://web.archive.org" + arch
|
return "https://" + archive_url_parser(header)
|
||||||
|
|
||||||
def get(self, url=None, user_agent=None, encoding=None):
|
def get(self, url=None, user_agent=None, encoding=None):
|
||||||
"""Returns the source code of the supplied URL. Auto detects the encoding if not supplied."""
|
"""Returns the source code of the supplied URL. Auto detects the encoding if not supplied."""
|
||||||
|
Reference in New Issue
Block a user