This repository has been archived by the owner on Jan 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformfill.py
142 lines (115 loc) · 4.31 KB
/
formfill.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#========================================
# Auto Denison Scheduler
#========================================
import re
import mechanize
import datetime
mechanize._sockettimeout._GLOBAL_DEFAULT_TIMEOUT = 1
#========================================
# Passwords and Pins
#========================================
student_id = "D********"
pin = "********"
alt_pin = "******"
#========================================
# Classes
#========================================
crn_1 = "*****"
crn_2 = "*****"
crn_3 = "*****"
crn_4 = "*****"
# *****
# Women's Studies - 40719
# Wicked Problems - 41110
# Operating Systems - 41012
# Cyber Ethics - 41190
# Ancient Rome - 41041
# Early British Literature - 40241
# ****
#========================================
# Scheduling Times
#========================================
time_1 = "20:00:01"
time_2 = "21:30:01"
#========================================
def main():
while True:
timestring = (datetime.datetime.now() + datetime.timedelta(seconds=30)).strftime("%H:%M:%S")
if timestring == time_1:
print "\n=========== Round 1 (" + time_1 + ") ===========\n"
registerCourse(crn_1, crn_2, time_1)
print "\n *** SUCCESS ***"
elif timestring == time_2:
print "\n=========== Round 2 (" + time_2 + ") ===========\n"
registerCourse(crn_3, crn_4, time_2)
print "\n *** SUCCESS ***\n"
break
#========================================
# A Function To Register Denison Courses
#========================================
def registerCourse(course1, course2, time):
print "Enter SSB: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
br = mechanize.Browser()
br.open("https://web4prod.denison.edu/pls/web4prod/bwskfreg.P_CheckAltPin")
# follow second link with element text matching regular expression
assert br.viewing_html()
# Login Page
br.select_form(name="loginform")
br.form["sid"] = student_id
br.form["PIN"] = pin
br.submit()
# Main Menu
for link in br.links():
if link.text == "Student Services":
br.follow_link(link)
break
# Student Services
for link in br.links():
if link.text == "Registration":
br.follow_link(link)
break
# Registration
for link in br.links():
if link.text == "Add or Drop Classes":
br.follow_link(link)
break
# Select Term
br.form = list(br.forms())[1]
br.submit()
print "Wait Before Alt Pin: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
while True:
if str(datetime.datetime.now().strftime("%H:%M:%S")) == time and int(datetime.datetime.now().microsecond) > 100000:
print "Enter Alt Pin: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
# Enter Alt Pin
br.form = list(br.forms())[1]
br.form['pin'] = alt_pin
br.submit()
try:
# Enter CRNs
print "Enter CRNs: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
br.form = list(br.forms())[1]
for control in br.form.controls:
if str(control.id) == "crn_id1":
control.value = course1
elif str(control.id) == "crn_id2":
control.value = course2
br.submit()
break
except:
print "Enter CRNs Failure: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
br.follow_link("https://web4prod.denison.edu/pls/web4prod/bwskfreg.P_CheckAltPin")
# Enter Alt Pin
br.form = list(br.forms())[1]
br.form['pin'] = alt_pin
br.submit()
br.form = list(br.forms())[1]
for control in br.form.controls:
if str(control.id) == "crn_id1":
control.value = course1
elif str(control.id) == "crn_id2":
control.value = course2
br.submit()
break
br.close()
print "End: ", datetime.datetime.now().strftime("%H:%M:%S.%f")
main()