mirror of
https://github.com/quatalog/quatalog.git
synced 2025-11-29 07:47:17 +00:00
Make failing actually fail the program
This commit is contained in:
parent
92c3327b1a
commit
81ba2fdc80
|
|
@ -98,11 +98,14 @@ def scrape_page(page_num):
|
||||||
jump_to_page(1, page_num, "gdvInstWithEQ", "lblInstWithEQPaginationInfo")
|
jump_to_page(1, page_num, "gdvInstWithEQ", "lblInstWithEQPaginationInfo")
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
driver.quit()
|
||||||
print(
|
print(
|
||||||
f"Attempt {i} failed to load page, retrying in 25 seconds...",
|
f"Attempt {i} failed to load page, retrying in 25 seconds...",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sleep(25)
|
sleep(25)
|
||||||
|
else:
|
||||||
|
raise Exception(f"Failed to load the main page after 15 attempts, aborting.")
|
||||||
|
|
||||||
num_institutions = len(
|
num_institutions = len(
|
||||||
driver.find_elements(
|
driver.find_elements(
|
||||||
|
|
@ -120,12 +123,14 @@ def scrape_institution_safe(index, page_num):
|
||||||
try:
|
try:
|
||||||
return scrape_institution(index, page_num)
|
return scrape_institution(index, page_num)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
driver.quit()
|
||||||
print(
|
print(
|
||||||
f"\tAttempt {i} failed due to {type(e).__name__}: {e}, retrying in 25 seconds...",
|
f"\tAttempt {i} failed due to {type(e).__name__}: {e}, retrying in 25 seconds...",
|
||||||
file=sys.stderr,
|
file=sys.stderr,
|
||||||
)
|
)
|
||||||
sleep(25)
|
sleep(25)
|
||||||
raise Exception(f"Failed to scrape {index} after 15 attempts, aborting.")
|
else:
|
||||||
|
raise Exception(f"Failed to scrape {index} after 15 attempts, aborting.")
|
||||||
|
|
||||||
|
|
||||||
# scrape_institution: Scrapes an institution by index.
|
# scrape_institution: Scrapes an institution by index.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue