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.
pxpmgajf2 9ea4128a17
Merge pull request 'master' (#1) from 大作业 into master
4 years ago
README.md Update README.md 4 years ago

README.md

GET

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

url=”https://www.bitpush.news/covid19/" headers = { “user-agent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36” } response=requests.get(url,headers=headers) html=response.text parse=etree.HTMLParser(encoding=utf-8) doc=etree.HTML(html) country=doc.xpath((//div[@class=”table_container”])[2]//tbody/tr/td/span/text()) person=doc.xpath((//div[@class=”table_container”])[2]//tbody/tr/td[2]/text()) death=doc.xpath((//div[@class=”table_container”])[2]//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)) with open(“content.csv”,”w”,encoding=utf-8-sig) as f: w=csv.writer(f) w.writerows(message) df=pandas.read_csv(“content.csv”,names=[“country”,”person”,”death”]) df.head() df.info() df1=df.drop(0).head(15) %matplotlib inline x=df1[country].values y=df1[death].values plt.rcParams[font.sans-serif] = [SimHei] plt.rcParams[figure.figsize] = (10, 5) plt.bar(x,y,color=g) plt.grid() plt.xlabel(‘地区’,fontsize=14) plt.ylabel(‘死亡人数’,fontsize=14) plt.show()