diff --git a/README.md b/README.md index 036313e..1cf5233 100644 --- a/README.md +++ b/README.md @@ -1,50 +1 @@ -#https://top.chinaz.com/gongsitop/index_500top. -import requests -import re -import csv -import pandas as pd -import matplotlib.pyplot as plt -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 -company = re.findall('(.+?)', html) -person = re.findall('法定代表人:(.+?)

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

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

', html) -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('(.+?)', html) - person = re.findall('法定代表人:(.*?)

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

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

', html) - pageOne = list(zip(company, person, signDate, category)) - message.extend(pageOne) -message -with open("content.csv", "w") as f: - w = csv.writer(f) - w.writerows(message) -!cat content.csv -df = pd.read_csv("content.csv", names=["company", "person", "signDate", "category"]) -df.head() -df.info() -df1 = df.groupby("category").count()["company"] -%matplotlib inline -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() \ No newline at end of file +https://top.chinaz.com/gongsitop/index_500top.