Skip to content

Instantly share code, notes, and snippets.

@rgardner
Created October 25, 2015 01:42
Show Gist options
  • Save rgardner/e54991509d98d909e3c3 to your computer and use it in GitHub Desktop.
Save rgardner/e54991509d98d909e3c3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# usage: meal_plans.py
import json
from selenium import webdriver
import time
# uncomment these lines to load your data from a file
#with open('config.json') as data_file:
# data = json.load(data_file)
data = { 'netid': 'INSERT_NETID_HERE', 'password': 'INSERT_PASSWORD_HERE' }
driver = webdriver.Firefox()
driver.get('https://home.nyu.edu')
# Login to NYU if necessary
if 'NYU Login' in driver.title:
driver.find_element_by_id('netid')
user = driver.find_element_by_id('netid')
user.send_keys(data['netid'])
password = driver.find_element_by_id('password')
password.send_keys(data['password'])
login = driver.find_element_by_css_selector('#login > input.uppercase.rounded')
login.click()
# Do Campus Cash specific things here
driver.get('https://home.nyu.edu/cgi-bin/login-campuscash.pl')
time.sleep(5)
balances = driver.find_elements_by_xpath("//*[contains(text(), 'Current Balance')]")
print("Campus Cash {0}".format(balances[0].text))
print("Dining Dollars {0}".format(balances[1].text))
print("Meals {0}".format(balances[2].text))
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment