提交 8a9ce091 作者: 薛凌堃

天眼查企业动态增量采集维护

上级 27dc9aa3
...@@ -27,7 +27,7 @@ cursor= cnx.cursor() ...@@ -27,7 +27,7 @@ cursor= cnx.cursor()
#根据信用代码获取天眼查id 企业名字等信息 #根据信用代码获取天眼查id 企业名字等信息
def getTycIdByXYDM(xydm): def getTycIdByXYDM(xydm):
retData={'state':False,'tycData':None} retData={'state':False,'tycData':None,'reput':True}
url=f"https://capi.tianyancha.com/cloud-tempest/search/suggest/v3?_={baseCore.getNowTime(3)}" url=f"https://capi.tianyancha.com/cloud-tempest/search/suggest/v3?_={baseCore.getNowTime(3)}"
ip = baseCore.get_proxy() ip = baseCore.get_proxy()
paramJsonData = {'keyword':xydm} paramJsonData = {'keyword':xydm}
...@@ -41,20 +41,21 @@ def getTycIdByXYDM(xydm): ...@@ -41,20 +41,21 @@ def getTycIdByXYDM(xydm):
pass pass
else: else:
log.error(f"---{xydm}-未查询到该企业---") log.error(f"---{xydm}-未查询到该企业---")
return retData['tycData'] retData['reput'] = False
return retData
matchType=retJsonData['data'][0]['matchType'] matchType=retJsonData['data'][0]['matchType']
if matchType=='信用代码匹配': if matchType=='信用代码匹配':
retData['state'] = True retData['state'] = True
retData['tycData'] = retJsonData['data'][0] retData['tycData'] = retJsonData['data'][0]
response.close() response.close()
return retData['tycData'] return retData
else: else:
log.error(f"{xydm}------{retJsonData}") log.error(f"{xydm}------{retJsonData}")
response.close() response.close()
return retData['tycData'] return retData
except: except:
log.error(f"---{xydm}--天眼查token失效---") log.error(f"---{xydm}--天眼查token失效---")
return retData['tycData'] return retData
# 更新天眼查企业基本信息 # 更新天眼查企业基本信息
......
...@@ -282,19 +282,21 @@ def doJob(): ...@@ -282,19 +282,21 @@ def doJob():
if tycid == None or tycid == '': if tycid == None or tycid == '':
try: try:
retData = getTycIdByXYDM(xydm) retData = getTycIdByXYDM(xydm)
if retData: if retData['tycData'] and retData['reput']:
tycid = retData['id'] tycid = retData['id']
# todo:写入数据库 # todo:写入数据库
updateSql = f"update EnterpriseInfo set TYCID = '{tycid}' where SocialCode = '{xydm}'" updateSql = f"update EnterpriseInfo set TYCID = '{tycid}' where SocialCode = '{xydm}'"
cursor_.execute(updateSql) cursor_.execute(updateSql)
cnx_.commit() cnx_.commit()
else: elif not retData['tycData'] and retData['reput']:
state = 0 state = 0
takeTime = baseCore.getTimeCost(start, time.time()) takeTime = baseCore.getTimeCost(start, time.time())
baseCore.recordLog(social_code, taskType, state, takeTime, '', '获取天眼查id失败') baseCore.recordLog(social_code, taskType, state, takeTime, '', '获取天眼查id失败')
log.info(f'======={social_code}====重新放入redis====') log.info(f'======={social_code}====重新放入redis====')
baseCore.rePutIntoR('NewsEnterprise:gnqy_socialCode', social_code) baseCore.rePutIntoR('NewsEnterprise:gnqy_socialCode', social_code)
continue continue
elif not retData['reput'] and not retData['tycData']:
continue
except: except:
state = 0 state = 0
takeTime = baseCore.getTimeCost(start, time.time()) takeTime = baseCore.getTimeCost(start, time.time())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论