-
Notifications
You must be signed in to change notification settings - Fork 0
/
get.py
88 lines (64 loc) · 2.36 KB
/
get.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import requests
import settings
urls = [
"charge_type2" "lecture_type2",
"exam_time_type2",
"time_type2",
"attend_type2",
"report_e_degree_k",
"kds_students_other_major",
]
headers = {"AUTH_KEY": settings.SCHOLAR_AUTH_KEY, "Content-Type": "application/json"}
def _get(url: str):
response = requests.get(
f"{settings.SCHOLAR_BASE_URL}{url}",
headers=headers,
)
response.encoding = "utf-8"
return response.json()
def get_charge_type(lecture_year: str = None, lecture_term: str = None):
params = []
if lecture_year:
params.append(f"lecture_year={lecture_year}")
if lecture_term:
params.append(f"lecture_term={lecture_term}")
return _get(f"/charge_type2?{'&'.join(params)}")["OutBlock_1"]
def get_lecture_type(lecture_year: str = None, lecture_term: str = None):
params = []
if lecture_year:
params.append(f"lecture_year={lecture_year}")
if lecture_term:
params.append(f"lecture_term={lecture_term}")
return _get(f"/lecture_type2?{'&'.join(params)}")["OutBlock_1"]
def get_exam_time_type(lecture_year: str = None, lecture_term: str = None):
params = []
if lecture_year:
params.append(f"lecture_year={lecture_year}")
if lecture_term:
params.append(f"lecture_term={lecture_term}")
return _get(f"/exam_time_type2?{'&'.join(params)}")["OutBlock_1"]
def get_time_type(lecture_year: str = None, lecture_term: str = None):
params = []
if lecture_year:
params.append(f"lecture_year={lecture_year}")
if lecture_term:
params.append(f"lecture_term={lecture_term}")
return _get(f"/time_type2?{'&'.join(params)}")["OutBlock_1"]
def get_attend_type(
lecture_year: str = None, lecture_term: str = None, student_no: str = None
):
params = []
if lecture_year:
params.append(f"lecture_year={lecture_year}")
if lecture_term:
params.append(f"lecture_term={lecture_term}")
if student_no:
params.append(f"student_no={student_no}")
return _get(f"/attend_type2?{'&'.join(params)}")["OutBlock_1"]
def get_report_e_degree_k(student_no: str = None):
params = []
if student_no:
params.append(f"student_no={student_no}")
return _get(f"/report_e_degree_k?{'&'.join(params)}")
def get_kds_students_other_major():
return _get("/kds_students_other_major")["OutBlock_1"]