|
|
|
@ -9,15 +9,14 @@ html = response.text
|
|
|
|
|
#print(html)
|
|
|
|
|
parse = etree.HTMLParser(encoding='utf-8')
|
|
|
|
|
doc = etree.HTML(html)
|
|
|
|
|
#states
|
|
|
|
|
states = doc.xpath('//div[@class="table_container"]//tbody/tr/td/span/text()')
|
|
|
|
|
print(states)
|
|
|
|
|
#print(states)
|
|
|
|
|
person = doc.xpath('//div[@class="table_container"]//tbody/tr/td[2]/text()')
|
|
|
|
|
print(person)
|
|
|
|
|
#print(person)
|
|
|
|
|
person = [x.replace(",", "") for x in person]
|
|
|
|
|
print(person)
|
|
|
|
|
#print(person)
|
|
|
|
|
death = doc.xpath('//div[@class="table_container"]//tbody/tr/td[3]/text()')
|
|
|
|
|
print(death)
|
|
|
|
|
#print(death)
|
|
|
|
|
death = [x.replace(",", "") for x in death]
|
|
|
|
|
message = list(zip(states, person, death))
|
|
|
|
|
import csv
|
|
|
|
@ -29,12 +28,12 @@ import pandas as pd
|
|
|
|
|
#读取数据
|
|
|
|
|
df = pd.read_csv("content.csv", names=["states", "person", "death"],encoding = 'gb2312')
|
|
|
|
|
df.head()
|
|
|
|
|
print(df)
|
|
|
|
|
#print(df)
|
|
|
|
|
for i in range(101):
|
|
|
|
|
df.drop([i],inplace=True)
|
|
|
|
|
print(df)
|
|
|
|
|
#print(df)
|
|
|
|
|
df.sort_values(by=['person'],ascending=False)
|
|
|
|
|
print(df)
|
|
|
|
|
#print(df)
|
|
|
|
|
df=df.iloc[0:158]
|
|
|
|
|
print(df)
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
@ -46,4 +45,3 @@ plt.bar(x, y)
|
|
|
|
|
plt.xlabel("states")
|
|
|
|
|
plt.ylabel("person")
|
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|