From 07670c4a741f743a0fb9997922701a56e2aa769c Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 20 Jan 2020 14:37:39 +1000 Subject: [PATCH] handle running out of posts gracefully --- app/scrape.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/scrape.py b/app/scrape.py index 3b0c753..5cbfbe7 100644 --- a/app/scrape.py +++ b/app/scrape.py @@ -80,9 +80,15 @@ def scrape_posts(account): if not done: if pleroma: - r = requests.get(j['next'], timeout = 10) + if 'next' in j: + r = requests.get(j['next'], timeout = 10) + else: + done = True else: - r = requests.get(j['prev'], timeout = 10) + if 'prev' in j: + r = requests.get(j['prev'], timeout = 10) + else: + done = True if r.status_code == 429: # we are now being ratelimited, move on to the next user