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
|
# Fix course titles accounting for Roman numerals up to X
|
||||||
def normalize_title(input):
|
def normalize_title(input):
|
||||||
s = " ".join(input.split())
|
s = " ".join(input.split())
|
||||||
|
@ -103,8 +107,14 @@ def scrape_page(page_num):
|
||||||
)
|
)
|
||||||
wait(EC.visibility_of_element_located((By.TAG_NAME, "body")))
|
wait(EC.visibility_of_element_located((By.TAG_NAME, "body")))
|
||||||
print(f'Title: "{driver.title}"', file=sys.stderr)
|
print(f'Title: "{driver.title}"', file=sys.stderr)
|
||||||
|
if driver.title == "403 Forbidden":
|
||||||
|
raise IPBanException
|
||||||
jump_to_page(1, page_num, "gdvInstWithEQ", "lblInstWithEQPaginationInfo")
|
jump_to_page(1, page_num, "gdvInstWithEQ", "lblInstWithEQPaginationInfo")
|
||||||
break
|
break
|
||||||
|
except IPBanException as e:
|
||||||
|
driver.quit()
|
||||||
|
print(f"We are IP-banned, exiting now", file=sys.stderr)
|
||||||
|
raise e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue