-
Notifications
You must be signed in to change notification settings - Fork 0
/
courseLookup.py
57 lines (48 loc) · 1.59 KB
/
courseLookup.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
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
import requests
def lookup(subject, number):
response = requests.head('https://www.albany.edu/registrar/schedule-of-classes-spring.php').status_code
if(response != 200):
return "down"
opts = Options()
opts.headless = True
assert opts.headless
browser = Chrome(options=opts)
browser.get('https://www.albany.edu/registrar/schedule-of-classes-spring.php')
search_form = browser.find_element_by_id('Course_Subject')
search_form.send_keys(subject)
search_form = browser.find_element_by_id('Course_Number')
search_form.send_keys(number)
search_form.submit()
results = browser.find_elements_by_tag_name('body')
list1 = []
body = ""
for i in results:
body += i.text
newbody = body[21:]
list1 = newbody.split("\n")
browser.close()
return list(list1)
def allInfo(group):
classNum = []
courseInfo = []
meetingInfo = []
seats = []
comments = []
for i in group:
if("Class Number:" in i):
sliced = i[14:]
classNum.append(sliced)
elif("Course Info:" in i):
sliced = i[13:]
courseInfo.append(sliced)
elif("Meeting Info:" in i):
sliced = i[14:]
meetingInfo.append(sliced)
elif("Seats" in i):
seats.append(i)
elif("Comments:" in i):
sliced = i[10:]
comments.append(sliced)
return list(classNum), list(courseInfo), list(meetingInfo), list(seats), list(comments)