Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
丁双波
zzsn_spider
Commits
a4e06d07
提交
a4e06d07
authored
9月 13, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
获取天眼查id脚本维护
上级
07886a4e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
48 行增加
和
34 行删除
+48
-34
getTycId.py
comData/tcyQydt/getTycId.py
+48
-34
没有找到文件。
comData/tcyQydt/getTycId.py
浏览文件 @
a4e06d07
...
...
@@ -22,9 +22,11 @@ headers = {
'version'
:
'TYC-Web'
,
'Content-Type'
:
'application/json;charset=UTF-8'
}
cnx
=
pymysql
.
connect
(
host
=
'114.116.44.11'
,
user
=
'caiji'
,
password
=
'f7s0&7qqtK'
,
db
=
'dbScore'
,
charset
=
'utf8mb4'
)
cursor
=
cnx
.
cursor
()
# cnx = pymysql.connect(host='114.116.44.11', user='caiji', password='f7s0&7qqtK', db='dbScore', charset='utf8mb4')
# cursor= cnx.cursor()
cnx_
=
baseCore
.
cnx
cursor_
=
BaseCore
.
cursor
taskType
=
'天眼查企业id/天眼查'
#根据信用代码获取天眼查id 企业名字等信息
def
getTycIdByXYDM
(
xydm
):
retData
=
{
'state'
:
False
,
'tycData'
:
None
,
'reput'
:
True
}
...
...
@@ -59,39 +61,51 @@ def getTycIdByXYDM(xydm):
# 更新天眼查企业基本信息
def
updateTycInfo
(
id
,
retData
):
state
=
retData
[
'state'
]
if
state
:
data
=
retData
[
'tycData'
]
updateSql
=
f
"update tyc_com_info set state=3,update_date=now(),tycid='{data['id']}', type='{data['type']}',comName='{data['comName']}',name='{data['name']}'"
\
f
",alias='{data['alias']}',logo='{data['logo']}',claimLevel='{data['claimLevel']}',regStatus='{data['regStatus']}' where id={id}"
els
e
:
updateSql
=
f
"update tyc_com_info set state=4,update_date=now() where id={id}"
cursor
.
execute
(
updateSql
)
cnx
.
commit
()
def
updateTycInfo
():
while
True
:
# 根据从Redis中拿到的社会信用代码,在数据库中获取对应基本信息
social_code
=
baseCore
.
redicPullData
(
'NewsEnterprise:gnqy_socialCode'
)
# social_code = '912301001275921118'
# 判断 如果Redis中已经没有数据,则等待
if
social_code
==
Non
e
:
time
.
sleep
(
20
)
continue
start
=
time
.
time
()
#采集工作
def
beginWork
():
while
True
:
start
=
time
.
time
()
selectSql
=
"select id,xydm from tyc_com_info where state=1 order by update_date asc ,id asc limit 1"
cursor
.
execute
(
selectSql
)
data
=
cursor
.
fetchone
()
if
data
:
data
=
baseCore
.
getInfomation
(
social_code
)
if
len
(
data
)
!=
0
:
pass
else
:
log
.
info
(
"没有数据了,结束脚本"
)
break
data_list
=
list
(
data
)
id
=
data_list
[
0
]
xydm
=
data_list
[
1
]
# 数据重新塞入redis
baseCore
.
rePutIntoR
(
'NewsEnterprise:gnqy_socialCode'
,
social_code
)
continue
xydm
=
data
[
2
]
tycid
=
data
[
11
]
if
tycid
==
None
or
tycid
==
''
:
try
:
retData
=
getTycIdByXYDM
(
xydm
)
updateTycInfo
(
id
,
retData
)
log
.
info
(
f
"{id}---{xydm}----处理完成,耗时:{baseCore.getTimeCost(start,time.time())}"
)
cursor
.
close
()
cnx
.
close
()
# 释放资源
baseCore
.
close
()
if
retData
[
'tycData'
]
and
retData
[
'reput'
]:
tycid
=
retData
[
'id'
]
# todo:写入数据库
updateSql
=
f
"update EnterpriseInfo set TYCID = '{tycid}' where SocialCode = '{xydm}'"
cursor_
.
execute
(
updateSql
)
cnx_
.
commit
()
elif
not
retData
[
'tycData'
]
and
retData
[
'reput'
]:
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
''
,
'获取天眼查id失败'
)
log
.
info
(
f
'======={social_code}====重新放入redis===='
)
baseCore
.
rePutIntoR
(
'NewsEnterprise:gnqy_socialCode'
,
social_code
)
continue
elif
not
retData
[
'reput'
]
and
not
retData
[
'tycData'
]:
continue
except
:
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
''
,
'获取天眼查id失败'
)
baseCore
.
rePutIntoR
(
'NewsEnterprise:gnqy_socialCode'
,
social_code
)
continue
if
__name__
==
'__main__'
:
beginWork
()
\ No newline at end of file
updateTycInfo
()
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论