-
Notifications
You must be signed in to change notification settings - Fork 0
/
crawling_json.py
34 lines (28 loc) · 945 Bytes
/
crawling_json.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
import json
from crawling_dataframe import convert_dataframe
def convert_json(type, result):
try:
data = json.loads(result)
if type == 'range_interest_ch':
convert_range_interest_ch(data)
elif type == '':
print("=========")
else:
print('==========')
except RuntimeError as e:
print(e)
# Skylife 관심채널 시청가구 변화추이
def convert_range_interest_ch(data):
temp = []
for item in data['chList']:
row = []
for temprow in item['list']:
listitem = {}
listitem['time'] = item['time']
listitem['prgm_id'] = temprow['prgm_id']
listitem['ch_no'] = temprow['ch_no']
listitem['ch_nm'] = temprow['ch_nm']
listitem['disp_ch_nm'] = temprow['disp_ch_nm']
listitem['view_cnt'] = temprow['view_cnt']
temp.append(listitem)
return temp