-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathGetData.py
More file actions
60 lines (37 loc) · 1.08 KB
/
GetData.py
File metadata and controls
60 lines (37 loc) · 1.08 KB
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
# encoding: utf-8
"""
@version: ??
@author: Andy
@file: GetData.py
@time: 20/2/4 20:57
"""
import requests
from redis_conn import redis_conn_pool
import json
rd = redis_conn_pool()
def get_ncovcity_data():
url = 'http://api.tianapi.com/txapi/ncovcity/index?key=d618ef42861ec00957dcacad6b69e8e0'
res = requests.get(url).json()
rd.set('ncovcity_data', json.dumps(res))
return res
def get_ncov_data():
url = 'http://api.tianapi.com/txapi/ncov/index?key=d618ef42861ec00957dcacad6b69e8e0'
res = requests.get(url).json()
rd.set('ncov_data', json.dumps(res))
return res
def get_trend_data():
headers = {
'user-agent': '',
'accept': ''
}
url = 'https://c.m.163.com/ug/api/wuhan/app/data/list-total'
res = requests.get(url, headers=headers).json()
rd.set('trend', json.dumps(res))
return res
if __name__ == '__main__':
trend = get_trend_data()
# print(trend['data']['areaTree'])
res = get_ncov_data()
res2 = get_ncovcity_data()
# print(res['newslist'])
# # print(res['newslist'][0]['provinceName'])