提交 06fc89ad 作者: 薛凌堃

财务数据部署

上级 3d4f1626
"""
"""
......@@ -8,10 +8,8 @@ import pandas as pd
from bs4 import BeautifulSoup
from base.BaseCore import BaseCore
baseCore = BaseCore()
cnx = pymysql.connect(host='114.116.44.11', user='caiji', password='f7s0&7qqtK', db='clb_project', charset='utf8mb4')
cursor = cnx.cursor()
cnx_ = baseCore.cnx
cursor_ = baseCore.cursor
cnx = baseCore.cnx_
cursor = baseCore.cursor_
log = baseCore.getLogger()
......@@ -442,27 +440,31 @@ def get_info(social_code, com_code,info_date,delist_all,info_date_list,taskType)
def getReportTime():
# timeNow = baseCore.getNowTime(1)[:10]
list_date = []
# 2023-04-01
#每月1号执行一次,
#todo:正式任务
# 获取当前日期和时间
current_date = datetime.now()
# 计算昨天的日期
yesterday = current_date - timedelta(days=1)
# yesterday = current_date - timedelta(days=1)
# 格式化昨天的日期
report_date = yesterday.strftime('%Y-%m-%d')
list_date.append(report_date)
# report_date = yesterday.strftime('%Y-%m-%d')
# list_date.append(report_date)
year = int(current_date.strftime('%Y'))
# list_date = ['2023-03-31']
# list_date = ['2023-09-30','2023-06-30','2023-03-31']
list_month = ['-12-31', '-09-30', '-06-30', '-03-31']
for year in range(2022, 2018, -1):
for year in range(year, 2018, -1):
for month in list_month:
date = str(year) + month
#todo:判断拼接的报告期是否大于当前日期,如果大于当前日期,怎说明还没到这个时间,跳过
current_date = current_date.strftime('%Y-%m-%d')
if current_date < date:
continue
list_date.append(date)
return list_date
def job(taskType):
def job(taskType,cnx,cursor):
# 将上市企业库中的全部A股代码存入list
# 需要提供股票代码、企业信用代码
flag = 0
......@@ -475,6 +477,9 @@ def job(taskType):
if social_code == None or social_code == 'None':
log.info('======已没有数据==========等待=====')
time.sleep(20)
if baseCore.check_mysql_conn(cnx):
cnx = baseCore.cnx
cursor = baseCore.cursor_
if flag == 0:
continue
elif flag == 1:
......@@ -564,7 +569,7 @@ def job(taskType):
if __name__=='__main__':
task_type = '财务数据/东方财富网'
job(task_type)
job(task_type,cnx,cursor)
东方财富网财务数据 部署在224服务器
东方财富网财务数据 部署在224服务器
每个月定时采集一次
等待时期,添加连接数据库测试,如果连接断开,重新连接上
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论