天使轮|基于阿里云 Serverless 函数计算开发的疫情数据统计推送机器人( 二 )


不足:文字单调 , 将在后期推出数据可视化版本 。
五、作品展示 项目代码:
import requestsrandomjson url = \"https://c.m.163.com/ug/api/wuhan/app/data/list-total\"def UserAgent(): #随机获取请求头 user_agent_list = ['Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML like Gecko) Chrome/28.0.1464.0 Safari/537.36' 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML like Gecko) Chrome/31.0.1650.16 Safari/537.36' 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML like Gecko) Chrome/35.0.3319.102 Safari/537.36' 'Mozilla/5.0 (X11; CrOS i686 3912.101.0) AppleWebKit/537.36 (KHTML like Gecko) Chrome/27.0.1453.116 Safari/537.36' 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/27.0.1453.93 Safari/537.36' 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/32.0.1667.0 Safari/537.36' 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:17.0) Gecko/20100101 Firefox/17.0.6' 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML like Gecko) Chrome/28.0.1468.0 Safari/537.36' 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML like Gecko) Chrome/41.0.2224.3 Safari/537.36' 'Mozilla/5.0 (X11; CrOS i686 3912.101.0) AppleWebKit/537.36 (KHTML like Gecko) Chrome/27.0.1453.116 Safari/537.36'
UserAgent={'User-Agent': random.choice(user_agent_list) return UserAgent def Get(arg1arg2): #获取疫情 url_json = requests.get(url=urlheaders=UserAgent()).json() today_confirm = str(url_json['data'
['chinaTotal'
['today'
['confirm'
)#全国累计确诊较昨日新增 today_input =str(url_json['data'
['chinaTotal'
['today'
['input'
)#全国较昨日新增境外输入 today_storeConfirm = str(url_json['data'
['chinaTotal'
['today'
['storeConfirm'
)#全国现有确诊较昨日 today_dead =str(url_json['data'
['chinaTotal'
['today'
['dead'
)#累计死亡较昨日新增 today_heal = str(url_json['data'
['chinaTotal'
['today'
['heal'
)#累计治愈较昨日新增 today_incrNoSymptom = str(url_json['data'
['chinaTotal'
['extData'
['incrNoSymptom'
)#无症状感染者较昨日 total_confirm = str(url_json['data'
['chinaTotal'
['total'
['confirm'
) # 全国累计确诊 total_input = str(url_json['data'
['chinaTotal'
['total'
['input'
) # 境外输入 total_dead = str(url_json['data'
['chinaTotal'
['total'
['dead'
) # 累计死亡 total_heal = str(url_json['data'
['chinaTotal'
['total'
['heal'
) # 累计治愈 total_storeConfirm = str(url_json['data'
['chinaTotal'
['total'
['confirm'
- url_json['data'
['chinaTotal'
['total'
['dead'
- url_json['data'
['chinaTotal'
['total'
['heal'
) # 全国现有确诊 total_noSymptom = str(url_json['data'
['chinaTotal'
['extData'
['noSymptom'
)#无症状感染者 lastUpdateTime = url_json['data'
['lastUpdateTime'
#截止时间 data ='https://mparticle.uc.cn/api/-' * 6 +'全国疫情数据实时统计' + '-' * 5 + '\统计截至时间:'+ lastUpdateTime +'\' + '-' * 27 + '\' + \\ ' 累计确诊:' + total_confirm + ' ; ' + '较昨日:' + today_confirm + \\ '\ 现有确诊:' + total_storeConfirm + ' ; ' + '较昨日:' + today_storeConfirm + \\ '\ 累计死亡:' + total_dead + ' ; ' + '较昨日:' + today_dead + \\ '\ 累计治愈:' + total_heal + ' ; ' + '较昨日:' + today_heal + \\ '\ 境外输入:' + total_input + ' ; ' + '较昨日:' + today_input + \\ '\ 无症状感染者:' + total_noSymptom + ' ; ' + '较昨日:' + today_incrNoSymptom print(data) HtmlPuch_server(data) def HtmlPuch_server(data): url_wx = \"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3b4bd7fa-4063-477f-bbc6-0fe767c52fdf\" headers = {\"Content-Type\": \"text/plain\" push_data =https://mparticle.uc.cn/api/{ /"msgtype\": \"text\" \"text\": { \"content\":datahtml = requests.post(url_wxheaders=headersjson=push_data) print(html.text) 使用阿里云函数计算FC服务:



使用定时触发器: