From d4bde2fd7a8f9a39f76fbfecb7e204f95a3b5950 Mon Sep 17 00:00:00 2001 From: powe97 <116031952+powe97@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:56:57 -0400 Subject: [PATCH] Add --crns-only --- PhotoScraper/RPI_SIS_PhotoScraper.py | 56 ++++++++++++++++------------ 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/PhotoScraper/RPI_SIS_PhotoScraper.py b/PhotoScraper/RPI_SIS_PhotoScraper.py index 2760137..c274979 100644 --- a/PhotoScraper/RPI_SIS_PhotoScraper.py +++ b/PhotoScraper/RPI_SIS_PhotoScraper.py @@ -48,6 +48,12 @@ action="store_true", help="keep clicking to avoid auto-timeout", ) +parser.add_argument( + "--crns_only", + default=False, + action="store_true", + help="Fetch CRNs for CSCI courses in upcoming term (used for testing)", +) args = parser.parse_args() @@ -621,6 +627,7 @@ def loopOverCourses(driver, term): # Assumes SIS main page is open def get_csci_crns(driver): + print("Fetching CSCI CRNs") driver.find_element(By.LINK_TEXT, "SITE MAP").click() driver.find_element(By.LINK_TEXT, "Class Search").click() @@ -648,26 +655,29 @@ def get_csci_crns(driver): if not success: driver.quit() else: - crns = get_csci_crns(driver) - print(crns) - # while True: - # # Get the term to use to save images - # term, success = selectTerm(driver) - - # if success: - # loopOverCourses(driver, term) - - # sttime = datetime.now().strftime("%Y%m%d %H:%M:%S") - # with open("last_completed_run.txt", "a") as logfile: - # logfile.write(sttime + " completed scrape\n") - - # if not args.run_forever: - # print( - # "--------------------\nlets NOT run forever\n--------------------" - # ) - # break - - # # wait a number of hours before doing it all again - # num_hours = 1 - # wasteTimeClicking(driver, 60 * 60 * num_hours) - # print("----------------\nLETS RUN FOREVER\n----------------") + if args.crns_only: + crns = get_csci_crns(driver) + print(crns) + sys.exit(0) + + while True: + # Get the term to use to save images + term, success = selectTerm(driver) + + if success: + loopOverCourses(driver, term) + + sttime = datetime.now().strftime("%Y%m%d %H:%M:%S") + with open("last_completed_run.txt", "a") as logfile: + logfile.write(sttime + " completed scrape\n") + + if not args.run_forever: + print( + "--------------------\nlets NOT run forever\n--------------------" + ) + break + + # wait a number of hours before doing it all again + num_hours = 1 + wasteTimeClicking(driver, 60 * 60 * num_hours) + print("----------------\nLETS RUN FOREVER\n----------------")