-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.py
executable file
·51 lines (33 loc) · 1.26 KB
/
search.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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from get_waitlists import get_waitlists
import time
import json
def search(course):
# Clicks on courses tab
tabButton = br.find_element_by_xpath('//*[@id="tabs"]/ul/li[4]/a')
tabButton.click()
# Types search terms for a course
element = br.find_element_by_xpath('//*[@id="courses"]')
element.clear()
element.send_keys(course)
# Submits form
element = br.find_element_by_xpath('//*[@id="socFacSubmit"]')
element.click()
element = br.find_element_by_xpath('//*[@id="socDisplayCVO"]/div[2]')
if "No Result Found." not in element.text:
get_waitlists(br.page_source, course)
else:
print("no" + course)
br.get("https://act.ucsd.edu/scheduleOfClasses/scheduleOfClassesStudent.htm")
chrome_options = Options()
chrome_options.add_argument("--headless")
br = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'./chromedriver.exe')
br.get("https://act.ucsd.edu/scheduleOfClasses/scheduleOfClassesStudent.htm")
# Chooses quarter
#element = br.find_element_by_xpath('//*[@id="selectedTerm"]/option[6]').click()
with open('./class_codes.json') as f:
data = json.load(f)
#for c in data:
search("CSE8a")
br.quit()