Add guard on failed page download.

pull/2/head v0.1.1
Joshua Potter 2023-11-28 07:57:05 -07:00
parent fe2e504de9
commit 3cc31f8f24
2 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,4 @@
from app import scraper from app import scraper
if __name__ == "__main__": if __name__ == "__main__":
scraper.run() scraper.run()

View File

@ -94,6 +94,9 @@ async def _scrape_all_coach_usernames(
print(f"Skipping {ANSI_COLOR(filepath)}") print(f"Skipping {ANSI_COLOR(filepath)}")
except FileNotFoundError: except FileNotFoundError:
page_usernames = await _scrape_page_coach_usernames(session, page_no) 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: with open(filepath, "w") as f:
for username in page_usernames: for username in page_usernames:
f.write(f"{username}\n") f.write(f"{username}\n")