From acaa93cf47d2bc15f65052e57250add5ae616509 Mon Sep 17 00:00:00 2001 From: James Jennett-Wheeler Date: Wed, 25 Jun 2025 14:59:24 +0100 Subject: [PATCH] Try twice before erroring --- app/monitor-planning.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/monitor-planning.py b/app/monitor-planning.py index 1d87cf7..eee14ed 100644 --- a/app/monitor-planning.py +++ b/app/monitor-planning.py @@ -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")