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.
hnu202111020205 0247cf158e
Update README.md
4 years ago
README.md Update README.md 4 years ago

README.md

world

import requests from lxml import etree import csv import pandas import matplotlib.pyplot as plt import numpy as np

if name == 'main': url="https://www.bitpush.news/covid19/" response=requests.get(url) html=response.text parse=etree.HTMLParser(encoding='utf-8') doc=etree.HTML(html) country=doc.xpath('//div[@class="table_container"]//tbody/tr/td/span/text()') person=doc.xpath('//div[@class="table_container"]//tbody/tr/td[2]/text()') death=doc.xpath('//div[@class="table_container"]//tbody/tr/td[3]/text()') person=[x.replace(",","") for x in person] death=[x.replace(",","") for x in death] message=list(zip(country,person,death)) %matplotlib inline with open("content.csv","w") as f: w=csv.writer(f) w.writerows(message) df=pandas.read_csv("content.csv",names=["country","person","death"]) df.head() df1=df.drop(0).head(10) x=df1['country'].values y=df1['death'].values plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus']=False plt.rcParams['figure.figsize'] = (10, 5) plt.bar(x,y) plt.xlabel('Countries',fontsize=14) plt.ylabel('Death',fontsize=14) plt.show()