feat:增加股票和订饭任务
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import requests
|
||||
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'
|
||||
|
||||
|
||||
def get_today_weather(city_location: int):
|
||||
def get_today_weather(city_location=nanjing_location):
|
||||
response = requests.get(
|
||||
f'{weather_url}v7/weather/3d',
|
||||
headers={
|
||||
@@ -20,7 +18,7 @@ def get_today_weather(city_location: int):
|
||||
return response.json()
|
||||
|
||||
|
||||
def get_today_indices(city_location: int):
|
||||
def get_today_indices(city_location=nanjing_location):
|
||||
response = requests.get(
|
||||
f'{weather_url}v7/indices/1d',
|
||||
headers={
|
||||
@@ -35,15 +33,11 @@ def get_today_indices(city_location: int):
|
||||
return response.json()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
weather = get_today_weather(nanjing_location)
|
||||
|
||||
def get_weather_message(weather, indices):
|
||||
textDay = weather['daily'][0]['textDay']
|
||||
textNight = weather['daily'][0]['textNight']
|
||||
weather_desc = textDay if textDay == textNight else f"{textDay}转{textNight}"
|
||||
|
||||
indices = get_today_indices(nanjing_location)
|
||||
|
||||
# 定义天气数据变量
|
||||
weather_data = {
|
||||
"city": "南京",
|
||||
@@ -55,11 +49,15 @@ if __name__ == '__main__':
|
||||
"humidity": weather['daily'][0]['humidity'] + "%",
|
||||
"wind": weather['daily'][0]['windDirDay'] + " " + weather['daily'][0]['windScaleDay'] + "级",
|
||||
"life_index": [
|
||||
{"type": "舒适度指数", "icon": "😊", "level": indices['daily'][7]['category'], "advice": indices['daily'][7]['text']},
|
||||
{"type": "穿衣指数", "icon": "👕", "level": indices['daily'][2]['category'], "advice": indices['daily'][2]['text']},
|
||||
{"type": "运动指数", "icon": "🏃", "level": indices['daily'][0]['category'], "advice": indices['daily'][0]['text']},
|
||||
{"type": "洗车指数", "icon": "🚗", "level": indices['daily'][1]['category'], "advice": indices['daily'][1]['text']}
|
||||
],
|
||||
{"type": "舒适度指数", "icon": "😊", "level": indices['daily'][7]['category'],
|
||||
"advice": indices['daily'][7]['text']},
|
||||
{"type": "穿衣指数", "icon": "👕", "level": indices['daily'][2]['category'],
|
||||
"advice": indices['daily'][2]['text']},
|
||||
{"type": "运动指数", "icon": "🏃", "level": indices['daily'][0]['category'],
|
||||
"advice": indices['daily'][0]['text']},
|
||||
{"type": "洗车指数", "icon": "🚗", "level": indices['daily'][1]['category'],
|
||||
"advice": indices['daily'][1]['text']}
|
||||
],
|
||||
"data_source": "中央气象台"
|
||||
}
|
||||
|
||||
@@ -87,11 +85,9 @@ if __name__ == '__main__':
|
||||
---
|
||||
*数据来源:{weather_data['data_source']}*"""
|
||||
|
||||
message = {
|
||||
return {
|
||||
"msgtype": "markdown_v2",
|
||||
"markdown_v2": {
|
||||
"content": markdown_content
|
||||
}
|
||||
}
|
||||
|
||||
send_wechat_message(message)
|
||||
|
||||
Reference in New Issue
Block a user