You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.9 KiB
51 lines
1.9 KiB
import requests
|
|
from bs4 import BeautifulSoup
|
|
import json
|
|
import re
|
|
|
|
|
|
def Mod_Summary_CN():
|
|
response = requests.get('https://voice.baidu.com/act/newpneumonia/newpneumonia/')
|
|
content = response.text
|
|
soup = BeautifulSoup(content, 'html.parser')
|
|
|
|
|
|
tag1 = soup.find('script', attrs={'id':'captain-config'})
|
|
tagstr = str(tag1)
|
|
res = re.findall(r'(\{".*?".*?\})',tagstr)
|
|
|
|
tagJson = json.loads(res[831])
|
|
|
|
temp1 = re.findall(r'("mapLastUpdatedTime":".*?")',tagstr)
|
|
temp2 = str(temp1[0])
|
|
time = temp2[22:len(temp2)-1:1]
|
|
|
|
|
|
summary = Summary()
|
|
summary.confirmed = int(tagJson['confirmed'])
|
|
summary.confirmedRelative = int(tagJson['confirmedRelative'])
|
|
summary.curConfirm = int(tagJson['curConfirm'])
|
|
summary.curConfirmRelative = int(tagJson['curConfirmRelative'])
|
|
summary.died = int(tagJson['died'])
|
|
summary.diedRelative = int(tagJson['diedRelative'])
|
|
summary.cured = int(tagJson['cured'])
|
|
summary.curedRelative = int(tagJson['curedRelative'])
|
|
summary.asymptomatic = int(tagJson['asymptomatic'])
|
|
summary.asymptomaticRelative = int(tagJson['asymptomaticRelative'])
|
|
summary.unconfirmed = int(tagJson['unconfirmed'])
|
|
summary.unconfirmedRelative = int(tagJson['unconfirmedRelative'])
|
|
summary.icu = int(tagJson['icu'])
|
|
summary.icuRelative = int(tagJson['icuRelative'])
|
|
summary.overseasInput = int(tagJson['overseasInput'])
|
|
summary.overseasInputRelative = int(tagJson['overseasInputRelative'])
|
|
summary.unOverseasInputCumulative = int(tagJson['unOverseasInputCumulative'])
|
|
summary.unOverseasInputNewAdd = int(tagJson['unOverseasInputNewAdd'])
|
|
summary.icuDisable = int(tagJson['icuDisable'])
|
|
|
|
|
|
#print('---------------------------------------------------------')
|
|
#print(' 更新时间:%s'%(time))
|
|
#print('---------------------------------------------------------')
|
|
#print(summary)
|
|
|