Try twice before erroring

This commit is contained in:
James Jennett-Wheeler 2025-06-25 14:59:24 +01:00
parent 0138b8dde2
commit acaa93cf47

View File

@ -44,7 +44,11 @@ def update_other_applications():
for search_week_idx in range(search_past_week,
min(search_past_week + search_num_weeks, 9)): # Council only allow latest 9 weeks
weekly_list.scrape(_browser, search_week_idx)
try:
weekly_list.scrape(_browser, search_week_idx)
except Exception:
# try one more time
weekly_list.scrape(_browser, search_week_idx)
there_were_newly_decided_applications = len(weekly_list.new_applications) > 0
print(" Number of new decided applications: " + str(len(weekly_list.new_applications)))
@ -60,7 +64,12 @@ def update_other_applications():
for (application_ref, ) in newly_decided_applications:
_app = Application(_cursor, application_ref)
_app.scrape_portal(_browser)
try:
_app.scrape_portal(_browser)
except Exception:
# try one more time
_app.scrape_portal(_browser)
if _app.caseOfficer == "Christopher Masters":
chris_decisions += 1
@ -84,7 +93,11 @@ if __name__ == '__main__':
application = Application(connection.cursor(), "25/00605/FUL")
with webdriver.Chrome(options=web_opts) as browser:
application.scrape_portal(browser, force=True, count_documents=True)
try:
application.scrape_portal(browser, force=True, count_documents=True)
except Exception:
# try one more time
application.scrape_portal(browser, force=True, count_documents=True)
if application.new_documents_found:
notify(f"New Documents Found: Application now has {application.num_documents} documents")