@@ -113,7 +113,6 @@ def saveImagesToFolder(term, course, class_list):
113
113
# download and save the image to a specific folder (term/course_section) from the image url
114
114
img_name = rcs_id + ".png"
115
115
filepath = path / img_name
116
- #TODO: Get SSL cipher setting to work with requests, right now still getting handshake errors
117
116
r = requests .get (img_url )
118
117
with open (str (filepath ),'wb' ) as f :
119
118
f .write (r .content )
@@ -137,12 +136,24 @@ def getStudentInfoFromCourse(driver, select_course, index, class_list):
137
136
# find link for pic
138
137
student_list = driver .find_elements_by_class_name ('datadisplaytable' )[2 ].find_element_by_tag_name ('tbody' ).find_elements_by_tag_name ('tr' )
139
138
139
+ # find which column is the "Student Name" column, since it isn't always the same column number
140
+ student_headers = student_list [0 ].find_elements_by_tag_name ('th' )
141
+ stu_col = - 1
142
+ for i in range (len (student_headers )):
143
+ if student_headers [i ].text == "Student Name" :
144
+ stu_col = i
145
+ if stu_col < 0 :
146
+ driver .back ()
147
+ driver .back ()
148
+ print ("Error: Could not find a column labeled \" Student Name\" !" )
149
+ return 0
150
+
140
151
# loop through list of students to get image, name, and email
141
152
# all info collected from for loop (img url, name, email) put into dict
142
153
for s in range (1 , len (student_list )):
143
154
student_record = {}
144
155
student = driver .find_elements_by_class_name ('datadisplaytable' )[2 ].find_element_by_tag_name ('tbody' ).find_elements_by_tag_name ('tr' )[s ]
145
- student .find_elements_by_tag_name ('td' )[1 ].find_element_by_class_name ('fieldmediumtext' ).click ()
156
+ student .find_elements_by_tag_name ('td' )[stu_col ].find_element_by_class_name ('fieldmediumtext' ).click ()
146
157
147
158
img_url = driver .current_url
148
159
driver .get (img_url )
@@ -219,6 +230,7 @@ def getInfoFromCourse(driver):
219
230
elif answer == "exit" :
220
231
return
221
232
elif answer == "y" :
233
+ print ("Getting student pictures... (this could take a few seconds per student)" )
222
234
# get the class list of dictionary of email, name, and image per student
223
235
class_list = getStudentInfoFromCourse (driver , select_course , index , class_list )
224
236
if class_list == 0 :
0 commit comments