国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網站運營 > A股網絡安全版塊公司市值排行

A股網絡安全版塊公司市值排行

時間:2023-06-15 19:42:02 | 來源:網站運營

時間:2023-06-15 19:42:02 來源:網站運營

A股網絡安全版塊公司市值排行:早上在公眾號隨手刷到了中國軟件公司市值排名,一時興起想要搜一下A股網絡安全版塊的公司市值排名,奈何搜了很久并沒有搜到現成的排名,而且公司市值會隨著每天公司的股價而波動,有些現成的排名已經是很久之前的了,因此沒有啥時效性。本著自己動手豐衣足食,隨手就擼了一個。文章會在每周五收盤后更新最新的A股網安公司市值排名,并一直維護下去。

import reimport osimport timeimport joblibimport asyncioimport aiohttpimport requests as rqimport pandas as pdimport matplotlib.pyplot as pltclass getTopSecCom: def __init__(self, top=None): self.headers = {"Referer": "http://quote.eastmoney.com/", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"} self.bk_url = "http://71.push2.eastmoney.com/api/qt/clist/get?cb=jQuery1124034348162124675374_1612595298605&pn=1&pz=85&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f62&fs=b:BK0655&fields=f12,f14&_=1612595298611" self.shares_api = "https://xueqiu.com/S/" self.top = top if not os.path.exists("./useful_sec_com_list"): self.useful_sec_com_list = self.get_sec_com_code() else: with open("./useful_sec_com_list", "rb") as fp: self.useful_sec_com_list = joblib.load(fp) def get_sec_com_code(self): html = rq.get(self.bk_url, headers=self.headers).content.decode("utf-8") sec_com_list = eval(re.findall("/[(.*?)/]", html)[0]) useful_sec_com_list = [[i["f12"], i["f14"]] for i in sec_com_list if "ST" not in i["f14"]] # 0和3開頭的為深證上市股票前綴為sz,6開頭的為上證上市股票前綴為sh for sec_com in useful_sec_com_list: if sec_com[0][0] == "6": sec_com[0] = "sh" + sec_com[0] else: sec_com[0] = "sz" + sec_com[0] with open("useful_sec_com_list", "wb") as fp: joblib.dump(useful_sec_com_list, fp) return useful_sec_com_list async def async_get_shares_details(self, sec_com, url): async with aiohttp.ClientSession() as session: async with session.get(url, headers=self.headers) as response: html = await response.text() market_value = re.search("<td>總市值:<span>(.*?)億</span>", html) if market_value: return [*sec_com, market_value.groups()[0]] async def async_get_all_shares(self): tasks = [] for sec_com in self.useful_sec_com_list: url = self.shares_api + sec_com[0] tasks.append( asyncio.create_task( self.async_get_shares_details(sec_com, url) ) ) done, pendding = await asyncio.wait(tasks) return [share.result() for share in done if share.result()] def get_shares_details(self): all_shares = [] for sec_com in self.useful_sec_com_list: url = self.shares_api + sec_com[0] response = rq.get(url, headers=self.headers).content.decode("utf-8") market_value = re.search("<td>總市值:<span>(.*?)億</span>", response) if market_value: all_shares.append([*sec_com, market_value.groups()[0]]) return all_shares def yield_picture(self, save_path): # all_shares = self.get_shares_details() # 同步代碼 all_shares = asyncio.run(self.async_get_all_shares()) # 異步代碼 df = pd.DataFrame(all_shares, columns=["股票代碼", "公司", "市值(億)"]) df["市值(億)"] = df["市值(億)"].astype(float) date = time.strftime("%Y年%m月%d日", time.localtime()) df.sort_values(by="市值(億)", ascending=False, inplace=True) df.index = range(1, df.shape[0]+1) plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False fig = plt.figure(dpi=400) ax = fig.add_subplot(111, frame_on=False) ax.xaxis.set_visible(False) ax.yaxis.set_visible(False) _ = pd.plotting.table(ax, df, loc="best", cellLoc="center") ax.set_title(f"{date}A股網安版塊公司市值排名", fontsize=10) plt.savefig(save_path, bbox_inches="tight")if __name__ == "__main__": m = getTopSecCom() m.yield_picture("rank.png")A股網絡安全版塊剔除ST后的公司市值排名情況如下



關鍵詞:排行,網絡,安全

74
73
25
news

版權所有? 億企邦 1997-2025 保留一切法律許可權利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點擊下載Chrome瀏覽器
關閉