Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
5899c4fb
提交
5899c4fb
authored
10月 09, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
天眼查企业动态维护
上级
d43a13da
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
13 行删除
+13
-13
tyc_qydt_add.py
comData/Tyc/tyc_qydt_add.py
+13
-13
没有找到文件。
comData/Tyc/tyc_qydt_add.py
浏览文件 @
5899c4fb
import
json
import
random
import
requests
,
time
,
pymysql
import
jieba
import
sys
...
...
@@ -45,24 +47,21 @@ def beinWork(tyc_code, social_code,start_time):
retData
=
{
'total'
:
0
,
'up_okCount'
:
0
,
'up_errorCount'
:
0
,
'up_repetCount'
:
0
}
t
=
time
.
time
()
url
=
f
'https://capi.tianyancha.com/cloud-yq-news/company/detail/publicmsg/news/webSimple?_={t}&id={tyc_code}&ps={pageSize}&pn=1&emotion=-100&event=-100'
for
m
in
range
(
0
,
3
)
:
try
:
try
:
for
m
in
range
(
0
,
3
)
:
ip
=
baseCore
.
get_proxy
()
headers
[
'User-Agent'
]
=
baseCore
.
getRandomUserAgent
()
response
=
requests
.
get
(
url
=
url
,
headers
=
headers
,
proxies
=
ip
,
verify
=
False
)
#
time.sleep(random.randint(3, 5))
time
.
sleep
(
random
.
randint
(
3
,
5
))
break
except
Exception
as
e
:
if
(
response
.
status_code
==
200
)
:
pass
if
(
response
.
status_code
==
200
):
pass
else
:
except
Exception
as
e
:
log
.
error
(
f
"{tyc_code}-----获取总数接口失败"
)
e
=
'获取总数接口失败'
e
rror
=
'获取总数接口失败'
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
url
,
e
)
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
url
,
f
'{error}----{e}'
)
return
retData
try
:
json_1
=
json
.
loads
(
response
.
content
.
decode
(
'utf-8'
))
...
...
@@ -177,7 +176,7 @@ def beinWork(tyc_code, social_code,start_time):
pass
continue
try
:
insert_sql
=
'''insert into brpa_source_article(social_credit_code,source_address,origin,type,
create_time) values(
%
s,
%
s,
%
s,
%
s,now())'''
insert_sql
=
'''insert into brpa_source_article(social_credit_code,source_address,origin,type,
publish_time,create_time) values(
%
s,
%
s,
%
s,
%
s,
%
s,now())'''
# 动态信息列表
up_okCount
=
up_okCount
+
1
list_info
=
[
...
...
@@ -185,6 +184,7 @@ def beinWork(tyc_code, social_code,start_time):
link
,
'天眼查'
,
'2'
,
time_format
]
cursor_
.
execute
(
insert_sql
,
tuple
(
list_info
))
cnx_
.
commit
()
...
...
@@ -214,10 +214,10 @@ def beinWork(tyc_code, social_code,start_time):
}
except
Exception
as
e
:
log
.
info
(
f
'传输失败:{social_code}----{link}'
)
e
=
'数据库传输失败'
e
rror
=
'数据库传输失败'
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
link
,
e
)
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
link
,
f
'{error}----{e}'
)
continue
# print(dic_news)
# 将相应字段通过kafka传输保存
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论