diff --git a/README.md b/README.md deleted file mode 100644 index 9adcb61..0000000 --- a/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# 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('(.+?)', 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('(.+?)', 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()