-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.get_rooms.py
More file actions
33 lines (21 loc) · 832 Bytes
/
1.get_rooms.py
File metadata and controls
33 lines (21 loc) · 832 Bytes
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
from json import dump
import requests
from config import session_id
url = "https://kep.kookmin.ac.kr/adm/afac/AfacsuCtr/findLendOkList.do?menuId=M104551&pgmId=P002506"
payload = "SSV:utf-8\u001eDataset:dsParam\u001e_RowType_\u001fmhrmlCd:STRING(256)\u001eU\u001f"
headers = {
'Content-Type': 'text/plain'
}
cookies = {
'SESSIONID': session_id
}
response = requests.post(url, headers=headers, cookies=cookies, data=payload)
records = []
data_head = list(map(lambda x: x.split(':')[0], response.text.split('\u001e')[3].split('\u001f')))
for data in response.text.split('\u001e')[4:]:
data = data.split('\u001f')
if len(data) != 20:
continue
records.append(dict(zip(data_head, data)))
with open('rooms.json', 'w', encoding='utf-8') as data:
dump(records, data, ensure_ascii=False, indent=2)