mirror of
https://github.com/quatalog/quatalog.git
synced 2024-12-27 07:06:41 +00:00
Short circuit on IP ban
This commit is contained in:
parent
ecfb176c46
commit
bdc6b2bcbc
|
@ -16,6 +16,10 @@ from selenium.common.exceptions import (
|
|||
)
|
||||
|
||||
|
||||
class IPBanException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# Fix course titles accounting for Roman numerals up to X
|
||||
def normalize_title(input):
|
||||
s = " ".join(input.split())
|
||||
|
@ -103,8 +107,14 @@ def scrape_page(page_num):
|
|||
)
|
||||
wait(EC.visibility_of_element_located((By.TAG_NAME, "body")))
|
||||
print(f'Title: "{driver.title}"', file=sys.stderr)
|
||||
if driver.title == "403 Forbidden":
|
||||
raise IPBanException
|
||||
jump_to_page(1, page_num, "gdvInstWithEQ", "lblInstWithEQPaginationInfo")
|
||||
break
|
||||
except IPBanException as e:
|
||||
driver.quit()
|
||||
print(f"We are IP-banned, exiting now", file=sys.stderr)
|
||||
raise e
|
||||
except Exception as e:
|
||||
driver.quit()
|
||||
|
||||
|
|
Loading…
Reference in a new issue