提交 119a9a33 作者: 薛凌堃

11/24

上级 c0b05e59
...@@ -540,19 +540,20 @@ if __name__ == '__main__': ...@@ -540,19 +540,20 @@ if __name__ == '__main__':
while True: while True:
nowtime = baseCore.getNowTime(1).replace('-', '')[:8] nowtime = baseCore.getNowTime(1).replace('-', '')[:8]
file_name = f'./data/国内企业基本信息采集情况_{nowtime}.xlsx' file_name = f'./data/国内企业基本信息采集情况.xlsx'
file.createFile(file_name) file.createFile(file_name)
cookieinfo = token.getToken() cookieinfo = token.getToken()
id_cookie = cookieinfo[0] if cookieinfo:
cookie_ = json.loads(cookieinfo[1])
# print(type(cookies))
if cookie_:
pass pass
else: else:
log.info('==========已无cookies==========') log.info('==========已无cookies==========')
time.sleep(30) time.sleep(30)
continue continue
id_cookie = cookieinfo[0]
cookie_ = json.loads(cookieinfo[1])
# print(type(cookies))
# cookie_ = json.loads(cookies) # cookie_ = json.loads(cookies)
# print(type(cookie_)) # print(type(cookie_))
log.info(f"获取cookie到----{cookie_}") log.info(f"获取cookie到----{cookie_}")
...@@ -621,7 +622,7 @@ if __name__ == '__main__': ...@@ -621,7 +622,7 @@ if __name__ == '__main__':
# exchange = '' # exchange = ''
count = redaytowork(com_name, social_code, securitiesCode, securitiesShortName, listingDate, category, exchange,ynDomestic, countryName, file_name) count = redaytowork(com_name, social_code, securitiesCode, securitiesShortName, listingDate, category, exchange,ynDomestic, countryName, file_name)
time.sleep(40) time.sleep(2)
# break # break
# baseCore.r.close() # baseCore.r.close()
# baseCore.sendEmail(file_name) # baseCore.sendEmail(file_name)
......
import os import os
...@@ -90,8 +90,8 @@ def getOBSres(pathType,name, response): ...@@ -90,8 +90,8 @@ def getOBSres(pathType,name, response):
return result return result
def secrchATT(item_id, retData, type_id): def secrchATT(item_id, retData, type_id):
sel_sql = f"select id from clb_sys_attachment where item_id = '{item_id}' and path = '{retData['path']}' and type_id={type_id} " sel_sql = '''select id from clb_sys_attachment where item_id = %s and path = %s and type_id=%s '''
cursor_.execute(sel_sql) cursor_.execute(sel_sql, (item_id, retData['path'], type_id))
selects = cursor_.fetchone() selects = cursor_.fetchone()
return selects return selects
...@@ -129,7 +129,7 @@ def tableUpdate(retData, com_name, year, pdf_name, num): ...@@ -129,7 +129,7 @@ def tableUpdate(retData, com_name, year, pdf_name, num):
print(e) print(e)
log.info(f"更新完成:{item_id}===={pdf_name+category}") log.info(f"更新完成:{item_id}===={pdf_name+category}")
try: try:
selects = secrchATT(item_id, pdf_name, type_id) selects = secrchATT(item_id, retData, type_id)
except Exception as e: except Exception as e:
log.info(e) log.info(e)
id = selects[0] id = selects[0]
...@@ -217,8 +217,8 @@ def GetContent(pdf_url,info_url, pdf_name, social_code, year, pub_time, start_ti ...@@ -217,8 +217,8 @@ def GetContent(pdf_url,info_url, pdf_name, social_code, year, pub_time, start_ti
# print(dic_news) # print(dic_news)
# 将相应字段通过kafka传输保存 # 将相应字段通过kafka传输保存
try: try:
producer = KafkaProducer(bootstrap_servers=['114.115.159.144:9092']) producer = KafkaProducer(bootstrap_servers=['114.115.159.144:9092'],max_request_size=1024*1024*20)
kafka_result = producer.send("researchReportTopicaaaas", kafka_result = producer.send("researchReportTopic",
json.dumps(dic_news, ensure_ascii=False).encode('utf8')) json.dumps(dic_news, ensure_ascii=False).encode('utf8'))
print(kafka_result.get(timeout=10)) print(kafka_result.get(timeout=10))
...@@ -342,7 +342,7 @@ def gonggao_info(dic_info): ...@@ -342,7 +342,7 @@ def gonggao_info(dic_info):
baseCore.recordLog(social_code, taskType, state, takeTime, pdf_url, '成功') baseCore.recordLog(social_code, taskType, state, takeTime, pdf_url, '成功')
# 发送kafka成功之后 再插入数据库 # 发送kafka成功之后 再插入数据库
insert = InsterInto(social_code, pdf_url, info_date, title) insert = InsterInto(social_code, info_url, info_date, title)
if insert: if insert:
log.info(f'===={social_code}========{title}=====插入库成功') log.info(f'===={social_code}========{title}=====插入库成功')
pass pass
...@@ -362,8 +362,8 @@ if __name__ =='__main__': ...@@ -362,8 +362,8 @@ if __name__ =='__main__':
while True: while True:
start_time = time.time() start_time = time.time()
# 获取企业信息 # 获取企业信息
# social_code = baseCore.redicPullData('NoticeEnterpriseEasteFinance:gnshqy_socialCode') social_code = baseCore.redicPullData('NoticeEnterprise:mgqy_socialCode_add')
social_code = 'ZZSN23030900000316' # social_code = 'ZZSN23030900000316'
if not social_code: if not social_code:
time.sleep(20) time.sleep(20)
continue continue
...@@ -378,8 +378,11 @@ if __name__ =='__main__': ...@@ -378,8 +378,11 @@ if __name__ =='__main__':
code = dic_info[3] code = dic_info[3]
com_name = dic_info[1] com_name = dic_info[1]
log.info(f'-----开始处理{com_name}----{social_code}------') log.info(f'-----开始处理{com_name}----{social_code}------')
gonggao_info(dic_info) try:
break gonggao_info(dic_info)
except:
log.info(f'-----error:{com_name}----{social_code}------')
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论