parent
b03fb3bb34
commit
6e7351a4a1
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/../../../../../:\PyCharm\文件\疫情数据分析\.idea/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# 基于编辑器的 HTTP 客户端请求
|
||||||
|
/httpRequests/
|
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (base)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/疫情数据分析.iml" filepath="$PROJECT_DIR$/.idea/疫情数据分析.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.7 (base)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
Binary file not shown.
@ -0,0 +1,25 @@
|
|||||||
|
class summaryDataOut:
|
||||||
|
confirmed=0
|
||||||
|
died=0
|
||||||
|
curConfirm=0
|
||||||
|
cured=0
|
||||||
|
confirmedRelative=0
|
||||||
|
curedRelative=0
|
||||||
|
diedRelative=0
|
||||||
|
curConfirmRelative=0
|
||||||
|
relativeTime=0
|
||||||
|
time=''
|
||||||
|
|
||||||
|
def blankNum (self,object):
|
||||||
|
return ' '*(12-len(str(object)))
|
||||||
|
|
||||||
|
def PrintOut(self):
|
||||||
|
print("截至%s国外疫情概况:"%self.time)
|
||||||
|
print("现有确诊:%d" % self.curConfirm, end=self.blankNum(self.curConfirm))
|
||||||
|
print("相对昨日新增:%d"%self.curConfirmRelative)
|
||||||
|
print("累计确诊:%d"%self.confirmed,end=self.blankNum(self.confirmed))
|
||||||
|
print("相对昨日新增:%d"%self.confirmedRelative)
|
||||||
|
print("累计治愈:%d"%self.cured,end=self.blankNum(self.cured))
|
||||||
|
print("相对昨日新增:%d"%self.curedRelative)
|
||||||
|
print("累计死亡:%d"%self.died,end=self.blankNum(self.died))
|
||||||
|
print("相对昨日新增:%d"%self.diedRelative)
|
@ -0,0 +1,34 @@
|
|||||||
|
import requests
|
||||||
|
import re
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import json
|
||||||
|
|
||||||
|
from 国外总数据 import summaryDataOut
|
||||||
|
|
||||||
|
# 获取数据
|
||||||
|
req = requests.get ('https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=osari_pc_3#tab4')
|
||||||
|
content = req.content.decode('utf-8')
|
||||||
|
soup = BeautifulSoup(content,'html.parser')
|
||||||
|
|
||||||
|
# 过滤筛选
|
||||||
|
tag = soup.find('script',attrs={'type':'application/json','id':'captain-config'})
|
||||||
|
tagstr=tag.string #标签转化为字符串
|
||||||
|
tagdic=json.loads(tagstr) #标签字符串转化为字典
|
||||||
|
component=tagdic['component'][0]
|
||||||
|
time= component['mapLastUpdatedTime']
|
||||||
|
result = component['summaryDataOut'] #字典中找出'component'key下的'summaryDataOut'key内容
|
||||||
|
|
||||||
|
# 存储
|
||||||
|
OutData=summaryDataOut()
|
||||||
|
|
||||||
|
OutData.confirmed=int(result['confirmed'])
|
||||||
|
OutData.confirmedRelative=int(result['confirmedRelative'])
|
||||||
|
OutData.cured=int(result['cured'])
|
||||||
|
OutData.curedRelative=int(result['curedRelative'])
|
||||||
|
OutData.died=int(result['died'])
|
||||||
|
OutData.diedRelative=int(result['diedRelative'])
|
||||||
|
OutData.curConfirm=int(result['curConfirm'])
|
||||||
|
OutData.curConfirmRelative=int(result['curConfirmRelative'])
|
||||||
|
OutData.time=time
|
||||||
|
|
||||||
|
OutData.PrintOut()
|
Loading…
Reference in new issue