提交 b58ca335 作者: 薛凌堃

最新版港股公告

上级 5d5fed47
""" """
""" """
港股公告-更换采用接口的方式 港股公告-更换采用接口的方式
""" """
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import os import os
import subprocess import subprocess
import sys import sys
...@@ -214,35 +215,6 @@ def ifInstert(short_name, social_code, title, info_date): ...@@ -214,35 +215,6 @@ def ifInstert(short_name, social_code, title, info_date):
else: else:
return ifexist return ifexist
def sendKafka(social_code,newsUrl,dic_news):
try:
producer = KafkaProducer(bootstrap_servers=['114.115.159.144:9092'], max_request_size=1024*1024*20)
kafka_result = producer.send("researchReportNoticeTopic",
json.dumps(dic_news, ensure_ascii=False).encode('utf8'))
print(kafka_result.get(timeout=10))
dic_result = {
'success': 'ture',
'message': '操作成功',
'code': '200',
}
log.info(dic_result)
return True
except Exception as e:
dic_result = {
'success': 'false',
'message': '操作失败',
'code': '204',
'e': e
}
state = 0
takeTime = baseCore.getTimeCost(start_time, time.time())
baseCore.recordLog(social_code, taskType, state, takeTime, newsUrl, 'Kafka操作失败')
log.info(dic_result)
return False
def GetContent(pdf_url,info_url, pdf_name, social_code, year, pub_time, start_time,com_name,num): def GetContent(pdf_url,info_url, pdf_name, social_code, year, pub_time, start_time,com_name,num):
# 上传至华为云服务器 # 上传至华为云服务器
retData = uptoOBS(pdf_url, pdf_name, 8, social_code) retData = uptoOBS(pdf_url, pdf_name, 8, social_code)
...@@ -326,7 +298,11 @@ def gonggao_info(dic_info): ...@@ -326,7 +298,11 @@ def gonggao_info(dic_info):
pass pass
else: else:
return return
while True:
if len(code.split('.HK')[0]) < 5:
code = '0' + code
else:
break
#https://np-anotice-stock.eastmoney.com/api/security/ann?sr=-1&page_size=50&page_index=1&ann_type=H&client_source=web&stock_list=00175&f_node=0 #https://np-anotice-stock.eastmoney.com/api/security/ann?sr=-1&page_size=50&page_index=1&ann_type=H&client_source=web&stock_list=00175&f_node=0
url = f'https://np-anotice-stock.eastmoney.com/api/security/ann?sr=-1&page_size=50&page_index=1&ann_type=H&client_source=web&stock_list={code.split(".HK")[0]}&f_node=0' url = f'https://np-anotice-stock.eastmoney.com/api/security/ann?sr=-1&page_size=50&page_index=1&ann_type=H&client_source=web&stock_list={code.split(".HK")[0]}&f_node=0'
for n1 in range(0, 3): for n1 in range(0, 3):
...@@ -414,7 +390,7 @@ def gonggao_info(dic_info): ...@@ -414,7 +390,7 @@ def gonggao_info(dic_info):
continue continue
else: else:
log.info(f'======={com_name}========{code}===已存在') log.info(f'======={com_name}========{code}===已存在')
continue return
if __name__ =='__main__': if __name__ =='__main__':
#从redis中读取social_code' #从redis中读取social_code'
...@@ -427,7 +403,7 @@ if __name__ =='__main__': ...@@ -427,7 +403,7 @@ if __name__ =='__main__':
start_time = time.time() start_time = time.time()
# 获取企业信息 # 获取企业信息
# social_code = baseCore.redicPullData('NoticeEnterprise:ggqy_socialCode_add') # social_code = baseCore.redicPullData('NoticeEnterprise:ggqy_socialCode_add')
social_code = '91330000747735638J' social_code = 'ZZSN23030800000224'
if not social_code: if not social_code:
time.sleep(20) time.sleep(20)
continue continue
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论