From 3cc31f8f242c4ce787937f499bc7d520e1693bf3 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Tue, 28 Nov 2023 07:57:05 -0700 Subject: [PATCH] Add guard on failed page download. --- app/__main__.py | 1 - app/scraper.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/__main__.py b/app/__main__.py index b72dfcc..06e23b7 100644 --- a/app/__main__.py +++ b/app/__main__.py @@ -1,5 +1,4 @@ from app import scraper - if __name__ == "__main__": scraper.run() diff --git a/app/scraper.py b/app/scraper.py index 5feb2c5..0df552f 100644 --- a/app/scraper.py +++ b/app/scraper.py @@ -94,6 +94,9 @@ async def _scrape_all_coach_usernames( print(f"Skipping {ANSI_COLOR(filepath)}") except FileNotFoundError: page_usernames = await _scrape_page_coach_usernames(session, page_no) + if not page_usernames: + print(f"Could not write {ANSI_COLOR(filepath)}") + continue with open(filepath, "w") as f: for username in page_usernames: f.write(f"{username}\n")