This commit is contained in:
aaron 2024-09-22 17:01:06 +08:00
parent f6bc443785
commit 0b34231b54
2 changed files with 17 additions and 13 deletions

View File

@ -29,7 +29,7 @@ for t in times:
schedule.every().day.at(t).do(macd_boll.run_crypto, interval = '4h')
#jin10
schedule.every().day.at("04:00").do(jin10.run)
schedule.every().day.at("00:00").do(jin10.run)
version = 'V1.21'
print(f'Running... {version}')

View File

@ -6,20 +6,16 @@ import discord_sender
def run():
print('金 10 数据数据日历数据抓取...')
now = datetime.date.today()
year = now.year
month = now.month
day = now.day
addtion_day = 1
items = []
while(addtion_day <= 7):
print(f'addtion_day:{addtion_day}')
day += addtion_day
addtion_day+=1
while(addtion_day <= 14):
data_day = datetime.datetime.now() + datetime.timedelta(days=addtion_day)
addtion_day = addtion_day + 1
result = _get_jin10_cal_by_day(year, month, day)
result = _get_jin10_cal_by_day(data_day.year, data_day.month, data_day.day)
items.extend(result)
time.sleep(1)
@ -30,18 +26,26 @@ def run():
print(item)
content += _build_content(item)
# print(content)
print(content)
url = 'https://discord.com/api/webhooks/1287027684370681939/fzinKKoNK6KXoLNdj1wttSDtIGio-VHijaYzZInoajHHu-PZyZXVpWDxM6_XrxCtPrPY'
discord_sender.send_message(url, '【最近一周数据公布',content)
discord_sender.send_message(url, '【最近重要数据公布时间',content)
def _build_content(item):
content = f"{item['name']} {item['country']} {item['time_period']}\r\n"
if item['previous'] != None:
content += f"前值: {item['previous']}\r\n"
if item['consensus'] != None:
content += f"预测值: {item['consensus']}\r\n"
content += f"重要星级:"
for s in range(item['star']):
content+=""
pub_date = datetime.datetime.strptime(item['pub_time'],'%Y-%m-%dT%H:%M:%S.%fZ') + datetime.timedelta(hours=8)
content += f"\r\n公布时间: {pub_date.strftime('%Y-%m-%d %H:%M:%S')}\r\n\r\n"
@ -54,7 +58,7 @@ def _fill_number(number):
def _get_jin10_cal_by_day(year,month, day):
url = f"https://cdn-rili.jin10.com/data/{year}/{_fill_number(month)}{_fill_number(day)}/economics.json"
print(url)
data = requests.get(url).json()
items = []