forked from yxjxx/bonds_reminder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_bonds.py
31 lines (27 loc) · 1.21 KB
/
main_bonds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import schedule
import logging
from get_all_data import get_data
from reminder import subscribe_reminder, winning_reminder, valid_bonds
"""主函数"""
def main():
# url = "http://dcfm.eastmoney.com/em_mutisvcexpandinterface/api/js/get?type=KZZ_LB2.0&token=70f12f2f4f091e459a279469fe49eca5" # 东方财富
url = "http://dcfm.eastmoney.com/em_mutisvcexpandinterface/api/js/get?type=KZZ_LB2.0&token=70f12f2f4f091e459a279469fe49eca5&p=1&st=STARTDATE&sr=-1&ps=50"
print(url)
json_data = get_data(url)
icals = valid_bonds(json_data)
# subscribe_reminder(json_data)
# winning_reminder(json_data)
print("*" * 40 + "\n\n\n")
if __name__ == '__main__':
try:
# main()
schedule.every().day.at('09:30').do(main) # 每天9:30执行一次
print("开始执行……")
while True:
schedule.run_pending()
except Exception as err:
logging.basicConfig(level=logging.DEBUG, # 控制台打印的日志级别
filename='bonds_error.log',
filemode='a',
format='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s' # 日志格式
)