-
Notifications
You must be signed in to change notification settings - Fork 0
/
umich.py
41 lines (31 loc) · 1.21 KB
/
umich.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
import requests
from bs4 import BeautifulSoup
import re
import sys ,time
start_time=time.time()
course = sys.argv[1]
response= requests.get("https://www.lsa.umich.edu/cg/cg_detail.aspx?content=2370"+course+"001&termArray=w_22_2370")
soup = BeautifulSoup(response.content,"html.parser" )
table=soup.findAll("div", {"id":"classScheduleBody"})
subj=soup.findAll("span", {"id":"contentMain_lblSubject_2"})
no=soup.findAll("span", {"id":"contentMain_lblCatNo_2"})
title=soup.findAll("span", {"id":"contentMain_lblLongTitle_2"})
sections= soup.findAll("div", {"class": "row clsschedulerow toppadding_main bottompadding_main"})
def is_lec(section):
return section.find("span", string=re.compile("LEC"))
def print_sections(section,inte):
number=section.find("div", string="Class No:")
section_no=number.find_parent().text
open_seats=section.find("div", string="Open Seats:").find_parent().text
result=re.findall('\d+', open_seats )
if is_lec(section):
print(f"No.{inte} has {result[0]} left")
return int(result[0])
return 0
i=1
total=0;
for section in sections:
total+=print_sections(section,i)
i+=1
print(F"Total left:{total}")
print("--- %s seconds ---" % (time.time() - start_time))