From 449fe40a93a3a79b5a4afccace3cc225abcf0a38 Mon Sep 17 00:00:00 2001 From: Cxx0822 <1556464090@qq.com> Date: Tue, 14 Oct 2025 16:50:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __pycache__/wechat_message.cpython-310.pyc | Bin 0 -> 639 bytes daily_stock.py | 38 +++++++++++++++++++++ daily_weather.py | 19 ++--------- wechat_message.py | 18 ++++++++++ 4 files changed, 58 insertions(+), 17 deletions(-) create mode 100644 __pycache__/wechat_message.cpython-310.pyc create mode 100644 daily_stock.py create mode 100644 wechat_message.py diff --git a/__pycache__/wechat_message.cpython-310.pyc b/__pycache__/wechat_message.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..653d6117b6c22e41891bcc82425e112b338cf9c7 GIT binary patch literal 639 zcmY*X&2H2%5VjL18|YRl%PVjRQZ@@MZMH%PX%TR$kl?ghY30O|#@pREYdhK>l^fT- zLwn>!cnDuPap3`a0eh*Sj5MD;98v)~dj!h$RBI%MGuW}PeY8DHXSa)Ye! z=xo~^iCROglTVulwg zq%vVcC0!^(7}YfHm`K911*L7K5lWlAyL(StIsX?}azl3K1gu>&mImrVFo-?r?&nxk zBWeX-kvy=8+v7KRMu+_PYOrR8pYr{^9#a;wqHg>VX9 QxtCIISA-(VO>ocu4N6 现价: {current_price}\n> 涨跌: {change_percent_rounded}%" + } + } + + send_wechat_message(message) \ No newline at end of file diff --git a/daily_weather.py b/daily_weather.py index 460bccd..707ba6a 100644 --- a/daily_weather.py +++ b/daily_weather.py @@ -1,14 +1,12 @@ import requests -import json from datetime import datetime +from wechat_message import send_wechat_message + weather_url = 'https://p478kygkjw.re.qweatherapi.com/' weather_api_key = '4aa47f183c694aaa812ff018be8270e4' nanjing_location = '101190101' -webhook_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send' -webhook_key = 'f09eb098-f709-4fc6-83b5-4a08a8431b8f' - def get_today_weather(city_location: int): response = requests.get( @@ -37,19 +35,6 @@ def get_today_indices(city_location: int): return response.json() -def send_wechat_message(message: str): - response = requests.post( - webhook_url, - headers={ - "Content-Type": "application/json" - }, - params={'key': webhook_key}, - data=json.dumps(message, ensure_ascii=False).encode('utf-8') - ) - - return response.json() - - if __name__ == '__main__': weather = get_today_weather(nanjing_location) diff --git a/wechat_message.py b/wechat_message.py new file mode 100644 index 0000000..d57e8e0 --- /dev/null +++ b/wechat_message.py @@ -0,0 +1,18 @@ +import requests +import json + +webhook_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send' +webhook_key = 'f09eb098-f709-4fc6-83b5-4a08a8431b8f' + + +def send_wechat_message(message: str): + response = requests.post( + webhook_url, + headers={ + "Content-Type": "application/json" + }, + params={'key': webhook_key}, + data=json.dumps(message, ensure_ascii=False).encode('utf-8') + ) + + return response.json() \ No newline at end of file