From ffb1df87a62e6703961e4c3f095582e9e698d44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Jan=C4=8Da=C5=99=C3=ADk?= Date: Mon, 30 Aug 2021 16:20:14 +0200 Subject: [PATCH] Raise error on a 509 response (too many sessions) When the response code is 509, raise an error with an explanation (based on the actual error message contained in the response HTML). --- waybackpy/wrapper.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/waybackpy/wrapper.py b/waybackpy/wrapper.py index 6b68d1c..a274e69 100644 --- a/waybackpy/wrapper.py +++ b/waybackpy/wrapper.py @@ -228,6 +228,13 @@ class Url: response=response, ) + if response.status_code == 509: + raise WaybackError( + "Can not save '{url}'. You have probably reached the limit of active sessions. Try later.".format( + url=_cleaned_url(self.url), text=response.text + ) + ) + m = re.search( r"https?://web.archive.org/web/([0-9]{14})/http", self._archive_url )