forked from mcjimsr/wwuregbot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
61 lines (45 loc) · 1.87 KB
/
main.py
File metadata and controls
61 lines (45 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Please only use this program in good faith.
# Software under the 0BSD license, aka do whatever you'd like with it!
import sched
import time
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from user import User
# TODO: define function, separate out smaller functions
def run_bot(user):
# Set browser to Chrome
browser = webdriver.Chrome(user.os)
# Go to registration page
browser.get('https://admin.wwu.edu/pls/wwis/bwskfreg.P_AltPin')
# Find username entry box
username_entry = browser.find_element_by_xpath("""//*[@id="username"]""")
# Send username to username entry box
username_entry.send_keys(user.get_username())
# Find password entry box
password_entry = browser.find_element_by_xpath("""//*[@id="password"]""")
# Send password to password entry box
password_entry.send_keys(user.get_password())
# Find "login" button, save to var
login_button = browser.find_element_by_xpath("""//*[@id="fm1"]/section[4]/input[4]""")
# Click "login" button
login_button.click()
# Find Term drop down menu
termselect = Select(browser.find_element_by_xpath("""//*[@id="term_id"]"""))
submit_button = browser.find_element_by_xpath("""/html/body/div[3]/form/input""")
submit_button.click()
CRN_id_num = 1
for CRN in user.CRNs:
crn_entry = browser.find_element_by_xpath(f"""//*[@id="crn_id{CRN_id_num}"]""")
crn_entry.send_keys(CRN)
CRN_id_num += 1
submit_CRNs = browser.find_element_by_xpath("""/html/body/div[3]/form/input[19]""")
submit_CRNs.click()
def run_bot_at_time(user: User):
scheduler = sched.scheduler(time.localtime, time.sleep)
scheduler.enterabs(time.strptime(user.registration_time), 0, run_bot)
scheduler.run()
if __name__ == "__main__":
user = User()
cd = user.get_user_os()
user.get_crn()
run_bot_at_time(user)