HaileyIsNotAPig commited on
Commit
4bc1931
·
verified ·
1 Parent(s): a1ee117

Update lib.py

Browse files
Files changed (1) hide show
  1. lib.py +26 -26
lib.py CHANGED
@@ -1,34 +1,34 @@
1
  import requests
2
- from bs4 import BeautifulSoup
3
 
4
- def crawler(url):
5
- response = requests.get(url)
6
- soup = BeautifulSoup(response.content, 'lxml')
7
- js = soup.select('script[type="text/javascript"]')
8
- dtxt = eval(js[6].text.split('\n\n')[1].strip('var timeDT = ').strip(';'))
9
 
10
- dl = []
11
- for item in dtxt:
12
- for element in item.values():
13
- if type(element[0])==dict:
14
- dl.append(element[0])
15
 
16
- # source: https://blog.csdn.net/fengqianlang/article/details/130080073
17
- data = list(
18
- {
19
- dictionary['cr_cono']: dictionary
20
- for dictionary in dl
21
- }.values()
22
- )
23
- return data
24
 
25
- def latest_semester():
26
- url = "https://gra206.aca.ntu.edu.tw/classrm/acarm/webcr-use-new"
27
- response = requests.get(url)
28
- soup = BeautifulSoup(response.content, 'lxml')
29
- op = soup.select('option')
30
- sem = op[0].text
31
- return sem
32
 
33
  def class_rooms():
34
  url = "https://gra206.aca.ntu.edu.tw/classrm/acarm/get-classroom-by-building"
 
1
  import requests
2
+ # from bs4 import BeautifulSoup
3
 
4
+ # def crawler(url):
5
+ # response = requests.get(url)
6
+ # soup = BeautifulSoup(response.content, 'lxml')
7
+ # js = soup.select('script[type="text/javascript"]')
8
+ # dtxt = eval(js[6].text.split('\n\n')[1].strip('var timeDT = ').strip(';'))
9
 
10
+ # dl = []
11
+ # for item in dtxt:
12
+ # for element in item.values():
13
+ # if type(element[0])==dict:
14
+ # dl.append(element[0])
15
 
16
+ # # source: https://blog.csdn.net/fengqianlang/article/details/130080073
17
+ # data = list(
18
+ # {
19
+ # dictionary['cr_cono']: dictionary
20
+ # for dictionary in dl
21
+ # }.values()
22
+ # )
23
+ # return data
24
 
25
+ # def latest_semester():
26
+ # url = "https://gra206.aca.ntu.edu.tw/classrm/acarm/webcr-use-new"
27
+ # response = requests.get(url)
28
+ # soup = BeautifulSoup(response.content, 'lxml')
29
+ # op = soup.select('option')
30
+ # sem = op[0].text
31
+ # return sem
32
 
33
  def class_rooms():
34
  url = "https://gra206.aca.ntu.edu.tw/classrm/acarm/get-classroom-by-building"