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.
hnu201807010805 53416c82ea
Update README.md
2 years ago
README.md Update README.md 2 years ago

README.md

index_500top

import requests url = "https://top.chinaz.com/gongsitop/index_500top.html" 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 html import re company = re.findall('<a.?target="blank">(.+?)', html) person = re.findall('法定代表人:(.+?)

', html) signDate = re.findall('注册时间:(.+?)

', html) category = re.findall('证券类别:(.+?)

', html) pageOne = list(zip(company, person, signDate, category)) message = [] for page in range(16): if page == 0: url = "https://top.chinaz.com/gongsitop/index_500top.html" else: url = "https://top.chinaz.com/gongsitop/index_500top
{}.html".format(page + 1) response = requests.get(url, headers=headers) html = response.text company = re.findall('<a.
?target="_blank">(.+?)', html) person = re.findall('法定代表人:(.?)

', html) signDate = re.findall('注册时间:(.
?)

', html) category = re.findall('证券类别:(.*?)

', html) pageOne = list(zip(company, person, signDate, category)) message.extend(pageOne) import csv with open("content.csv", "w") as f: w = csv.writer(f) w.writerows(message) !cat content.csv import pandas as pd df = pd.read_csv("content.csv", names=["company", "person", "signDate", "category"]) df.head() df.info() df1 = df.groupby("category").count()["company"] df1 %matplotlib inline import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei']
labels = df1.index sizes = df1.values fig1, ax1 = plt.subplots() ax1.pie(sizes, labels=labels, autopct='%d%%',radius=2,textprops={'fontsize': 20}, shadow=False, startangle=90) ax1.axis() plt.show()