(self, save_path)
| 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 | |
| 93 | if __name__ == "__main__": |
| 94 | m = getTopSecCom() |
no test coverage detected