From 8859522ef16868382d58c139c6eee2dff8b678ca Mon Sep 17 00:00:00 2001 From: Stefan Karner Date: Tue, 7 May 2019 15:56:14 +0200 Subject: [PATCH] Add utility functions to parse full text search responses --- webarchiv.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/webarchiv.py b/webarchiv.py index 189c7b1..ee597e8 100644 --- a/webarchiv.py +++ b/webarchiv.py @@ -305,7 +305,21 @@ class WebarchivSession: print('Error:'.format(query_string)) def getSnapshotUrl(self, seed, capture, onlysvg): - return self.api_path + 'snapshot?capture=' + capture + '&t=' + self.token + '&apikey=' + self.api_key + '&onlysvg=' + onlysvg + '&seed=' + seed; + return self.api_path + 'snapshot?capture=' + capture + '&t=' + self.token + '&apikey=' + self.api_key + '&onlysvg=' + onlysvg + '&seed=' + seed + + @staticmethod + def resultContainsSeeds(response): + try: + return response.json()['subtype'] == 2 + except: + return False + + @staticmethod + def resultContainsCaptures(response): + try: + return response.json()['subtype'] == 3 + except: + return False def savePage(self, url): self.connect() -- GitLab