feat:增加股票和订饭任务
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import requests
|
||||
|
||||
from wechat_message import send_wechat_message
|
||||
|
||||
stock_url = 'http://push2.eastmoney.com/api/qt/stock/get'
|
||||
estun_id = '0.002747'
|
||||
|
||||
def get_today_stock(company_id: str):
|
||||
|
||||
def get_today_stock(company_id=estun_id):
|
||||
response = requests.get(
|
||||
stock_url,
|
||||
params={'secid': company_id}
|
||||
@@ -14,25 +13,21 @@ def get_today_stock(company_id: str):
|
||||
return response.json()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
stock = get_today_stock(estun_id)
|
||||
|
||||
def get_stock_message(stock):
|
||||
# 获取真实数据
|
||||
current_price = stock['data']['f43'] / 100
|
||||
current_price = stock['data']['f43'] / 100
|
||||
prev_close = stock['data']['f60'] / 100
|
||||
|
||||
|
||||
# 计算涨跌幅
|
||||
change_percent = (current_price - prev_close) / prev_close * 100
|
||||
change_percent_rounded = round(change_percent, 2)
|
||||
|
||||
|
||||
# 根据涨跌确定颜色
|
||||
color = "warning" if change_percent < 0 else "info"
|
||||
|
||||
message = {
|
||||
|
||||
return {
|
||||
"msgtype": "markdown",
|
||||
"markdown": {
|
||||
"content": f"📈 **埃斯顿(002747)**\n> 现价: <font color=\"{color}\">{current_price}</font>\n> 涨跌: <font color=\"{color}\">{change_percent_rounded}%</font>"
|
||||
"content": f"📈 **埃斯顿(002747)**\n> 现价: <font color=\"{color}\">{current_price}元</font>\n> 涨跌: <font color=\"{color}\">{change_percent_rounded}%</font>"
|
||||
}
|
||||
}
|
||||
|
||||
send_wechat_message(message)
|
||||
Reference in New Issue
Block a user