From 6ff6c0e8b01b84d44787937eaf04f180f1cd76bb Mon Sep 17 00:00:00 2001 From: cheney Date: Mon, 21 Jul 2025 20:55:01 +0800 Subject: [PATCH] save --- Dockerfile | 4 ++++ main.py | 6 ++++++ pushplus.py | 34 ++++++++++++++++++++++++++++++++++ sh000300.py | 14 ++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 Dockerfile create mode 100644 main.py create mode 100644 pushplus.py create mode 100644 sh000300.py diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5085f6c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM ubuntu:latest +LABEL authors="Cheney" + +ENTRYPOINT ["top", "-b"] \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e975e02 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +import akshare as ak +import sh000300 + +if __name__ == '__main__': + print(ak.__version__) + sh000300.day() diff --git a/pushplus.py b/pushplus.py new file mode 100644 index 0000000..630780f --- /dev/null +++ b/pushplus.py @@ -0,0 +1,34 @@ +import requests +import json +import logging + +logger = logging.getLogger(__name__) +token = "14d265653e8247dcbdefb7d83d1fe26e" +url = "https://www.pushplus.plus/send" +headers = { + "Content-Type": "application/json" +} + +def send_msg(title, content): + logger.info("msg title: {}".format(title)) + logger.info("msg content: {}".format(content)) + payload = { + "token": token, + "title": title, + "content": content, + "template": "html", + "channel": "wechat" + } + + response = requests.post(url, headers=headers, data=json.dumps(payload)) + logger.info("response code: {}".format(response.status_code)) + logger.info("response data: {}".format(response.text)) + return { + "code" : response.status_code, + "data" : response.text + } + + +if __name__ == '__main__': + ret = send_msg("Python 测试", "测试通知内容") + print(ret) \ No newline at end of file diff --git a/sh000300.py b/sh000300.py new file mode 100644 index 0000000..b75c228 --- /dev/null +++ b/sh000300.py @@ -0,0 +1,14 @@ +import akshare as ak + + +def day(): + # 获取收盘价 + index_data = ak.stock_zh_index_daily(symbol="sh000300") # 上海证券交易所代码 sh000300 + latest_close = index_data.iloc[-1]["close"] # 获取最新收盘价 + print(f"沪深300指数(000300)最新收盘价: {latest_close}") + + # 获取沪深300指数实时行情(需在交易时间段内运行) + # index_realtime = ak.stock_zh_ah_spot() # 获取所有指数实时行情 + # sh000300_realtime = index_realtime[index_realtime["代码"] == "000300"] # 筛选沪深300指数 + # current_price = sh000300_realtime["最新价"].values[0] + # print(f"沪深300指数(000300)当前实时价格: {current_price}") \ No newline at end of file