Skip to content

Commit

Permalink
Add --crns-only
Browse files Browse the repository at this point in the history
  • Loading branch information
powe97 committed Jul 16, 2024
1 parent 645f61f commit d4bde2f
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions PhotoScraper/RPI_SIS_PhotoScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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----------------")

0 comments on commit d4bde2f

Please sign in to comment.