1580788920
This repo holds the code for crawling the latest news on the pneumonia virus from Clove doctor’s website
The content of the crawling includes the number of confirmed cases, the number of suspected cases, the progress of relevant research (source of infection, route of transmission, etc.), the number of infected cases in various provinces and the latest 3 real-time news
If you don’t see your province in an infected province, it may be because no cases have been found, but that doesn’t mean you can let your guard down
It may be faster for domestic users to download EXE files through this link
The function of 2019-ncov-timer. py program is to crawl the data at 0:00 am every day, and save it in the current sheet with the date of the day as the sheet name. The program was written to make it easier for researchers to analyze data
Please read the following notes carefully
Part of the data in Excel are as follows:
This project was written by me after staying up late for 2 hours in the evening. I just hope to call on all of you to give full play to your strengths, use what you have learned and do something within your capacity for the prevention and control of the epidemic. You can say that my project is rubbish, but please don’t say that I am trying to make a show. No Chinese would make a show of this kind of thing
My power is limited, you can help optimize the code to make it simpler, or you can do some awesome projects, such as data visualization of epidemic transmission. I will also continue to improve the project, welcome to ask more questions. Thanks
I’ll soon deploy the data I’ve crawled to the server as json, so you can call it
import requests
import re
from bs4 import BeautifulSoup
from time import sleep
import json
from prettytable import ALL
from prettytable import PrettyTable
hubei = {}
guangdong = {}
zhejiang = {}
beijing = {}
shanghai = {}
hunan = {}
anhui = {}
chongqing = {}
sichuan = {}
shandong = {}
guangxi = {}
fujian = {}
jiangsu = {}
henan = {}
hainan = {}
tianjin = {}
jiangxi = {}
shanxi1 = {} # 陕西
guizhou = {}
liaoning = {}
xianggang = {}
heilongjiang = {}
aomen = {}
xinjiang = {}
gansu = {}
yunnan = {}
taiwan = {}
shanxi2 = {} # 山西
jilin = {}
hebei = {}
ningxia = {}
neimenggu = {}
qinghai = {} # none
xizang = {} # none
provinces_idx = [hubei, guangdong, zhejiang, chongqing, hunan, anhui, beijing,
shanghai, henan, guangxi, shandong, jiangxi, jiangsu, sichuan,
liaoning, fujian, heilongjiang, hainan, tianjin, hebei, shanxi2,
yunnan, xianggang, shanxi1, guizhou, jilin, gansu, taiwan,
xinjiang, ningxia, aomen, neimenggu, qinghai, xizang]
map = {
'湖北':0, '广东':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
}
def getTime(text):
TitleTime = str(text)
TitleTime = re.findall('<span>(.*?)</span>', TitleTime)
return TitleTime[0]
def getAllCountry(text):
AllCountry = str(text)
AllCountry = AllCountry.replace("[<p class=\"confirmedNumber___3WrF5\"><span class=\"content___2hIPS\">", "")
AllCountry = AllCountry.replace("<span style=\"color: #4169e2\">", "")
AllCountry = re.sub("</span>", "", AllCountry)
AllCountry = AllCountry.replace("</p>]", "")
AllCountry = AllCountry.replace("<span style=\"color: rgb(65, 105, 226);\">", "")
AllCountry = re.sub("<span>", "", AllCountry)
AllCountry = re.sub("<p>", "", AllCountry)
AllCountry = re.sub("</p>", "", AllCountry)
return AllCountry
def query(province):
table = PrettyTable(['地区', '确诊', '死亡', '治愈'])
for (k, v) in province.items():
name = k
table.add_row([name, v[0] if v[0] != 0 else '-', v[1] if v[1] != 0 else '-', v[2] if v[2] != 0 else '-'])
if len(province.keys()) != 0:
print(table)
else:
print("暂无")
def getInfo(text):
text = str(text)
text = re.sub("<p class=\"descText___Ui3tV\">", "", text)
text = re.sub("</p>", "", text)
return text
def is_json(json_str):
try:
json.loads(json_str)
except ValueError:
return False
return True
def ff(str, num):
return str[:num] + str[num+1:]
def main():
url = "https://3g.dxy.cn/newh5/view/pneumonia"
try:
headers = {}
headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' #http头大小写不敏感
headers['accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
headers['Connection'] = 'keep-alive'
headers['Upgrade-Insecure-Requests'] = '1'
r = requests.get(url, headers=headers)
r.raise_for_status()
r.encoding = r.apparent_encoding
soup = BeautifulSoup(r.text,'lxml')
table = PrettyTable(['地区', '确诊', '死亡', '治愈'])
table.hrules = ALL
#### 截至时间
# TitleTime = getTime(soup.select('.title___2d1_B'))
print()
# print(" ",TitleTime + "\n")
while True:
r = requests.get("https://service-f9fjwngp-1252021671.bj.apigw.tencentcs.com/release/pneumonia")
json_str = json.loads(r.text)
if json_str['error'] == 0:
break
print("==================================全国数据==================================")
print()
print(" 确诊 " + str(json_str['data']['statistics']['confirmedCount']) + " 例"
+ " " + "疑似 " + str(json_str['data']['statistics']['suspectedCount']) + " 例"
+ " " + "死亡" + str(json_str['data']['statistics']['deadCount']) + " 例"
+ " " + "治愈" + str(json_str['data']['statistics']['curedCount']) + " 例\n")
print("==================================相关情况==================================")
print()
print("传染源:" + json_str['data']['statistics']['infectSource'])
print("病毒:" + json_str['data']['statistics']['virus'])
print("传播途径:" + json_str['data']['statistics']['passWay'])
print(json_str['data']['statistics']['remark1'])
print(json_str['data']['statistics']['remark2'] + "\n")
print("==================================国内情况==================================")
print()
json_provinces = re.findall("{\"provinceName\":(.*?)]}", str(soup))
idx = 0
for province in json_provinces:
if is_json(province):
pass
else:
province = "{\"provinceName\":" + province + "]}"
province = json.loads(province)
province_name = province['provinceShortName'] if province['provinceShortName'] != 0 else '-'
confirmed = province['confirmedCount'] if province['confirmedCount'] != 0 else '-'
suspected = province['suspectedCount'] if province['suspectedCount'] != 0 else '-'
cured = province['curedCount'] if province['curedCount'] != 0 else '-'
dead = province['deadCount'] if province['deadCount'] != 0 else '-'
table.add_row([province_name, confirmed, dead, cured])
map[province_name] = idx
idx = idx + 1
for city in province['cities']:
provinces_idx[map[province_name]][city['cityName']] = [city['confirmedCount'], city['deadCount'], city['curedCount']]
print(table)
print()
print("==================================国外情况==================================")
print()
json_provinces = str(re.findall("\"id\":949(.*?)]}", str(soup)))
json_provinces = json_provinces[:1] + "{\"id\":949" + json_provinces[2:]
json_provinces = json_provinces[:len(json_provinces) - 2] + json_provinces[len(json_provinces) - 1:]
provinces = json.loads(json_provinces)
table = PrettyTable(['地区', '确诊', '死亡', '治愈'])
for province in provinces:
confirmed = province['confirmedCount'] if province['confirmedCount'] != 0 else '-'
dead = province['deadCount'] if province['deadCount'] != 0 else '-'
cured = province['curedCount'] if province['curedCount'] != 0 else '-'
table.add_row([province['provinceName'], confirmed, dead, cured])
print(table)
print()
print("==================================最新消息==================================")
print()
idx = 0
for news in json_str['data']['timeline']:
if idx == 5:
break
print(news['pubDateStr'] + " " + news['title'])
idx = idx + 1
print()
key = input("请输入您想查询详细信息的省份,例如 湖北\n")
print()
if key in map.keys():
query(provinces_idx[map[key]])
else:
print("暂无相关信息")
print("\n欢迎提出各种意见")
except:
print("连接失败")
if __name__ == '__main__':
main()
sleep(30)
#python #corona #coronavirus
1619518440
Welcome to my Blog , In this article, you are going to learn the top 10 python tips and tricks.
…
#python #python hacks tricks #python learning tips #python programming tricks #python tips #python tips and tricks #python tips and tricks advanced #python tips and tricks for beginners #python tips tricks and techniques #python tutorial #tips and tricks in python #tips to learn python #top 30 python tips and tricks for beginners
1621644000
Data management, analytics, data science, and real-time systems will converge this year enabling new automated and self-learning solutions for real-time business operations.
The global pandemic of 2020 has upended social behaviors and business operations. Working from home is the new normal for many, and technology has accelerated and opened new lines of business. Retail and travel have been hit hard, and tech-savvy companies are reinventing e-commerce and in-store channels to survive and thrive. In biotech, pharma, and healthcare, analytics command centers have become the center of operations, much like network operation centers in transport and logistics during pre-COVID times.
While data management and analytics have been critical to strategy and growth over the last decade, COVID-19 has propelled these functions into the center of business operations. Data science and analytics have become a focal point for business leaders to make critical decisions like how to adapt business in this new order of supply and demand and forecast what lies ahead.
In the next year, I anticipate a convergence of data, analytics, integration, and DevOps to create an environment for rapid development of AI-infused applications to address business challenges and opportunities. We will see a proliferation of API-led microservices developer environments for real-time data integration, and the emergence of data hubs as a bridge between at-rest and in-motion data assets, and event-enabled analytics with deeper collaboration between data scientists, DevOps, and ModelOps developers. From this, an ML engineer persona will emerge.
#analytics #artificial intelligence technologies #big data #big data analysis tools #from our experts #machine learning #real-time decisions #real-time analytics #real-time data #real-time data analytics
1620466520
If you accumulate data on which you base your decision-making as an organization, you should probably think about your data architecture and possible best practices.
If you accumulate data on which you base your decision-making as an organization, you most probably need to think about your data architecture and consider possible best practices. Gaining a competitive edge, remaining customer-centric to the greatest extent possible, and streamlining processes to get on-the-button outcomes can all be traced back to an organization’s capacity to build a future-ready data architecture.
In what follows, we offer a short overview of the overarching capabilities of data architecture. These include user-centricity, elasticity, robustness, and the capacity to ensure the seamless flow of data at all times. Added to these are automation enablement, plus security and data governance considerations. These points from our checklist for what we perceive to be an anticipatory analytics ecosystem.
#big data #data science #big data analytics #data analysis #data architecture #data transformation #data platform #data strategy #cloud data platform #data acquisition
1593156510
At the end of 2019, Python is one of the fastest-growing programming languages. More than 10% of developers have opted for Python development.
In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.
Table of Contents hide
III Built-in data types in Python
The Size and declared value and its sequence of the object can able to be modified called mutable objects.
Mutable Data Types are list, dict, set, byte array
The Size and declared value and its sequence of the object can able to be modified.
Immutable data types are int, float, complex, String, tuples, bytes, and frozen sets.
id() and type() is used to know the Identity and data type of the object
a**=25+**85j
type**(a)**
output**:<class’complex’>**
b**={1:10,2:“Pinky”****}**
id**(b)**
output**:**238989244168
a**=str(“Hello python world”)****#str**
b**=int(18)****#int**
c**=float(20482.5)****#float**
d**=complex(5+85j)****#complex**
e**=list((“python”,“fast”,“growing”,“in”,2018))****#list**
f**=tuple((“python”,“easy”,“learning”))****#tuple**
g**=range(10)****#range**
h**=dict(name=“Vidu”,age=36)****#dict**
i**=set((“python”,“fast”,“growing”,“in”,2018))****#set**
j**=frozenset((“python”,“fast”,“growing”,“in”,2018))****#frozenset**
k**=bool(18)****#bool**
l**=bytes(8)****#bytes**
m**=bytearray(8)****#bytearray**
n**=memoryview(bytes(18))****#memoryview**
Numbers are stored in numeric Types. when a number is assigned to a variable, Python creates Number objects.
#signed interger
age**=**18
print**(age)**
Output**:**18
Python supports 3 types of numeric data.
int (signed integers like 20, 2, 225, etc.)
float (float is used to store floating-point numbers like 9.8, 3.1444, 89.52, etc.)
complex (complex numbers like 8.94j, 4.0 + 7.3j, etc.)
A complex number contains an ordered pair, i.e., a + ib where a and b denote the real and imaginary parts respectively).
The string can be represented as the sequence of characters in the quotation marks. In python, to define strings we can use single, double, or triple quotes.
# String Handling
‘Hello Python’
#single (') Quoted String
“Hello Python”
# Double (") Quoted String
“”“Hello Python”“”
‘’‘Hello Python’‘’
# triple (‘’') (“”") Quoted String
In python, string handling is a straightforward task, and python provides various built-in functions and operators for representing strings.
The operator “+” is used to concatenate strings and “*” is used to repeat the string.
“Hello”+“python”
output**:****‘Hello python’**
"python "*****2
'Output : Python python ’
#python web development #data types in python #list of all python data types #python data types #python datatypes #python types #python variable type
1619510796
Welcome to my Blog, In this article, we will learn python lambda function, Map function, and filter function.
Lambda function in python: Lambda is a one line anonymous function and lambda takes any number of arguments but can only have one expression and python lambda syntax is
Syntax: x = lambda arguments : expression
Now i will show you some python lambda function examples:
#python #anonymous function python #filter function in python #lambda #lambda python 3 #map python #python filter #python filter lambda #python lambda #python lambda examples #python map