MCPcopy
hub / github.com/yhangf/PythonCrawler / yield_picture

Method yield_picture

spiderFile/get_top_sec_com.py:72–91  ·  view source on GitHub ↗
(self, save_path)

Source from the content-addressed store, hash-verified

70 return all_shares
71
72 def yield_picture(self, save_path):
73 # all_shares = self.get_shares_details() # 同步代码
74 all_shares = asyncio.run(self.async_get_all_shares()) # 异步代码
75 df = pd.DataFrame(all_shares, columns=["股票代码", "公司", "市值(亿)"])
76 df["市值(亿)"] = df["市值(亿)"].astype(float)
77 date = time.strftime("%Y年%m月%d日", time.localtime())
78 df.sort_values(by="市值(亿)", ascending=False, inplace=True)
79 df.index = range(1, df.shape[0]+1)
80
81 plt.rcParams['font.sans-serif'] = ['SimHei']
82 plt.rcParams['axes.unicode_minus'] = False
83
84
85 fig = plt.figure(dpi=400)
86 ax = fig.add_subplot(111, frame_on=False)
87 ax.xaxis.set_visible(False)
88 ax.yaxis.set_visible(False)
89 _ = pd.plotting.table(ax, df, loc="best", cellLoc="center")
90 ax.set_title(f"{date}A股网安版块公司市值排名", fontsize=10)
91 plt.savefig(save_path, bbox_inches="tight")
92
93if __name__ == "__main__":
94 m = getTopSecCom()

Callers 1

get_top_sec_com.pyFile · 0.80

Calls 2

async_get_all_sharesMethod · 0.95
runMethod · 0.80

Tested by

no test coverage detected