Skip to content

Commit d4bde2f

Browse files
committed
Add --crns-only
1 parent 645f61f commit d4bde2f

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

PhotoScraper/RPI_SIS_PhotoScraper.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
action="store_true",
4949
help="keep clicking to avoid auto-timeout",
5050
)
51+
parser.add_argument(
52+
"--crns_only",
53+
default=False,
54+
action="store_true",
55+
help="Fetch CRNs for CSCI courses in upcoming term (used for testing)",
56+
)
5157

5258
args = parser.parse_args()
5359

@@ -621,6 +627,7 @@ def loopOverCourses(driver, term):
621627

622628
# Assumes SIS main page is open
623629
def get_csci_crns(driver):
630+
print("Fetching CSCI CRNs")
624631
driver.find_element(By.LINK_TEXT, "SITE MAP").click()
625632
driver.find_element(By.LINK_TEXT, "Class Search").click()
626633

@@ -648,26 +655,29 @@ def get_csci_crns(driver):
648655
if not success:
649656
driver.quit()
650657
else:
651-
crns = get_csci_crns(driver)
652-
print(crns)
653-
# while True:
654-
# # Get the term to use to save images
655-
# term, success = selectTerm(driver)
656-
657-
# if success:
658-
# loopOverCourses(driver, term)
659-
660-
# sttime = datetime.now().strftime("%Y%m%d %H:%M:%S")
661-
# with open("last_completed_run.txt", "a") as logfile:
662-
# logfile.write(sttime + " completed scrape\n")
663-
664-
# if not args.run_forever:
665-
# print(
666-
# "--------------------\nlets NOT run forever\n--------------------"
667-
# )
668-
# break
669-
670-
# # wait a number of hours before doing it all again
671-
# num_hours = 1
672-
# wasteTimeClicking(driver, 60 * 60 * num_hours)
673-
# print("----------------\nLETS RUN FOREVER\n----------------")
658+
if args.crns_only:
659+
crns = get_csci_crns(driver)
660+
print(crns)
661+
sys.exit(0)
662+
663+
while True:
664+
# Get the term to use to save images
665+
term, success = selectTerm(driver)
666+
667+
if success:
668+
loopOverCourses(driver, term)
669+
670+
sttime = datetime.now().strftime("%Y%m%d %H:%M:%S")
671+
with open("last_completed_run.txt", "a") as logfile:
672+
logfile.write(sttime + " completed scrape\n")
673+
674+
if not args.run_forever:
675+
print(
676+
"--------------------\nlets NOT run forever\n--------------------"
677+
)
678+
break
679+
680+
# wait a number of hours before doing it all again
681+
num_hours = 1
682+
wasteTimeClicking(driver, 60 * 60 * num_hours)
683+
print("----------------\nLETS RUN FOREVER\n----------------")

0 commit comments

Comments
 (0)