def checkSpecificReservation(driver, mountain, month, day, year, monthsToCheck): """Checks for specific reservation and reserves if available """ # reload to allow new mountain selection driver.get(makeResUrl) selectMountain(driver, mountain) selectMonth(driver, monthsToCheck[month], year) if isDayAvailable(driver, monthsToCheck[month], day, year): # reserve day reserveSuccess = reserveDay(driver, monthsToCheck[month], day, year, mountain) # return to make reservation page driver.get(makeResUrl) # get day of week dayOfWeek = datetime.date(year, month, day).strftime("%A") # send alert if reserveSuccess: emailInterface.sendDateToReserveAlertEmail(ikonEmail, mountain, monthsToCheck[month], str(day), str(year), dayOfWeek, ikonEmail)
def checkForOpenings(driver, datesAvailable, datesToReserve, mountainsToCheck, monthsToCheck): """Checks if any reserved days have become available by scraping Ikon site and comparing to the current stored available dates in our list. Reserves days that are set in database if they become available. """ # check current available dates for mountain in mountainsToCheck: # reload to allow new mountain selection url = "https://account.ikonpass.com/en/myaccount/add-reservations/" driver.get(url) selectMountain(driver, mountain) for month in monthsToCheck: selectMonth(driver, monthsToCheck[month], year) for day in range(1, calendar.monthrange(year, month)[1] + 1): if isDayAvailable(driver, monthsToCheck[month], day, year): # check if date is in datesToReserve and reserve if so if [str(month), str(day), str(year), mountain] in datesToReserve: reserveSuccess = reserveDay(driver, monthsToCheck[month], day, year, mountain) # return to make reservation page driver.get(makeResUrl) # get day of week dayOfWeek = datetime.date(year, month, day).strftime("%A") # send alert if reserveSuccess: emailInterface.sendDateToReserveAlertEmail( ikonEmail, mountain, monthsToCheck[month], str(day), str(year), dayOfWeek, ikonEmail) # refresh scraper selectMountain(driver, mountain) selectMonth(driver, monthsToCheck[month], year) # if day is not stored as available send alert if desire and # add to available dates if [mountain, month, day, year] not in datesAvailable: # get day of week dayOfWeek = datetime.date(year, month, day).strftime("%A") # send alerts if desired if ALERT_ALL_OPENINGS: emailInterface.sendReservationOpenAlertEmail( ikonEmail, mountain, monthsToCheck[month], str(day), str(year), dayOfWeek, ikonEmail) # add to list datesAvailable.append([mountain, month, day, year]) else: # if day is not available but stored as available, remove it # from list if [mountain, month, day, year] in datesAvailable: datesAvailable.remove([mountain, month, day, year])