From 9cef8b278cb6f78ad9693181a07834b4d83ebd38 Mon Sep 17 00:00:00 2001 From: egg23333 <806261011@qq.com> Date: Wed, 12 Aug 2020 10:48:01 +0800 Subject: [PATCH] remove CNSummary.py --- CNsummary.py | 80 ---------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 CNsummary.py diff --git a/CNsummary.py b/CNsummary.py deleted file mode 100644 index 2b27817..0000000 --- a/CNsummary.py +++ /dev/null @@ -1,80 +0,0 @@ -import requests -import re -import time -from bs4 import BeautifulSoup -import lxml -import json - -class summary_cn: - def __init__(self): - self.confirmed = 0 - self.died = 0 - self.cured = 0 - self.asymptomatic = 0 - self.asymptomaticRelative = 0 - self.unconfirmed = 0 - self.relativeTime = 0 - self.confirmedRelative = 0 - self.unconfirmedRelative = 0 - self.curedRelative = 0 - self.diedRelative = 0 - self.icu = 0 - self.icuRelative = 0 - self.overseasInput = 0 - self.unOverseasInputCumulative = 0 - self.overseasInputRelative = 0 - self.unOverseasInputNewAdd = 0 - self.curConfirm = 0 - self.curConfirmRelative = 0 - self.icuDisable = 0 - def __str__(self): - t = float(self.relativeTime) - lt = time.localtime(t) - string = '截止' + time.strftime('%Y-%m-%d %H:%M:%S',lt)+'\n' - string+= "国内现有\n\t确诊:" + str(self.curConfirm) + '\t较昨日' + str(self.curConfirmRelative) - string+="\n\t无症状:" + str(self.asymptomatic) + '\t较昨日' + str(self.asymptomaticRelative) - string+='\n\t重症:' + str(self.icu) + '\t较昨日' + str(self.icuRelative) - string+='\n\t疑似:' + str(self.unconfirmed) + '\t\t较昨日' + str(self.unconfirmedRelative) - string+='\n累计:\n\t确诊' + str(self.confirmed) + '\n\t治愈' + str(self.cured) - string+='\n\t死亡' + str(self.died) - return string - -def undefined_D(): - headers = { - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/53\ - 7.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36' - } - res = requests.get("https://voice.baidu.com/act/newpneumonia/newpneumonia/") - txt = res.content.decode("utf-8") - soup = BeautifulSoup(txt,'html.parser') - tag = soup.find('script',attrs={'id':'captain-config'}) - tagjs = json.loads(tag.string) - ans = tagjs['component'][0]['summaryDataIn'] - print(ans) - sum = summary_cn() - sum.confirmed = int(ans['confirmed']) - sum.died = int(ans['died']) - sum.cured = int(ans['cured']) - sum.asymptomatic = int(ans['asymptomatic']) - sum.asymptomaticRelative = int(ans['asymptomaticRelative']) - sum.unconfirmed = int(ans['unconfirmed']) - sum.relativeTime = int(ans['relativeTime']) - sum.confirmedRelative = int(ans['confirmedRelative']) - sum.unconfirmedRelative = int(ans['unconfirmedRelative']) - sum.curedRelative = int(ans['curedRelative']) - sum.diedRelative = int(ans['diedRelative']) - sum.icu = int(ans['icu']) - sum.icuRelative = int(ans['icuRelative']) - sum.overseasInput = int(ans['overseasInput']) - sum.unOverseasInputCumulative = int(ans['unOverseasInputCumulative']) - sum.overseasInputRelative = int(ans['overseasInputRelative']) - sum.unOverseasInputNewAdd = int(ans['unOverseasInputNewAdd']) - sum.curConfirm = int(ans['curConfirm']) - sum.curConfirmRelative = int(ans['curConfirmRelative']) - sum.icuDisable = int(ans['icuDisable']) - - return sum - - -if __name__ == "__main__": - undefined_D()