Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
丁双波
zzsn_spider
Commits
060ce7c4
提交
060ce7c4
authored
8月 12, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2023/8/12
上级
aedff657
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
63 行增加
和
61 行删除
+63
-61
fbs_annualreport.py
comData/annualReport_ZJH/fbs_annualreport.py
+0
-0
fbs_notice.py
comData/noticeReport_ZJH/fbs_notice.py
+63
-61
没有找到文件。
comData/annualReport_ZJH/fbs_annualreport.py
浏览文件 @
060ce7c4
差异被折叠。
点击展开。
comData/noticeReport_ZJH/fbs_notice.py
浏览文件 @
060ce7c4
...
...
@@ -261,76 +261,78 @@ def SpiderByZJH(url, payload, dic_info, start_time): # dic_info 数据库中获
if
soup
==
''
:
return
False
# 先获取页数
page
=
0
try
:
page
=
soup
.
find
(
'div'
,
class_
=
'pages'
)
.
find
(
'ul'
,
class_
=
'g-ul'
)
.
text
except
:
e
=
f
"该企业没有{dic_parms['Catagory2']}数据"
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
dic_parms
[
'url'
],
'Kafka操作失败
'
)
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
dic_parms
[
'url'
],
f
'{e}
'
)
return
False
total
=
re
.
findall
(
r'\d+'
,
page
)[
0
]
if
page
!=
0
:
total
=
re
.
findall
(
r'\d+'
,
page
)[
0
]
r_page
=
int
(
total
)
%
15
if
r_page
==
0
:
Maxpage
=
int
(
total
)
//
15
else
:
Maxpage
=
int
(
total
)
//
15
+
1
log
.
info
(
f
'{short_name}====={code}===========一共{total}条,{Maxpage}页'
)
# 首页和其他页不同,遍历 如果是首页 修改一下链接
for
i
in
range
(
1
,
Maxpage
+
1
):
log
.
info
(
f
'==========正在采集第{i}页========='
)
if
i
==
1
:
href
=
url
r_page
=
int
(
total
)
%
15
if
r_page
==
0
:
Maxpage
=
int
(
total
)
//
15
else
:
# http://eid.csrc.gov.cn/101811/index_3_f.html
href
=
url
.
split
(
'index'
)[
0
]
+
f
'index_{i}_f.html'
soup
=
RequestUrl
(
href
,
payload
,
social_code
,
start_time
)
if
soup
==
''
:
continue
tr_list
=
soup
.
find
(
'div'
,
id
=
'txt'
)
.
find_all
(
'tr'
)
pageIndex
=
0
for
tr
in
tr_list
[
1
:]:
pageIndex
+=
1
td_list
=
tr
.
find_all
(
'td'
)
pdf_url_info
=
td_list
[
2
]
# print(pdf_url)
pdf_url
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
0
]
.
strip
(
'
\'
'
)
name_pdf
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
1
]
.
strip
(
'
\'
'
)
pub_time
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
2
]
.
strip
(
'
\'
'
)
year
=
pub_time
[:
4
]
report_type
=
td_list
[
4
]
.
text
.
strip
()
# 信息插入数据库
insert
=
InsterInto
(
short_name
,
social_code
,
name_pdf
,
pub_time
,
pdf_url
,
report_type
)
log
.
info
(
f
'======={short_name}========{code}===插入公告库成功'
)
if
insert
:
# # 公告信息列表
# okCount = okCount + 1
# 解析PDF内容,先获取PDF链接 下载 解析成功,解析失败 ,传输成功,传输失败
result
=
GetContent
(
pdf_url
,
name_pdf
,
social_code
,
year
,
pub_time
,
start_time
)
if
result
:
# 公告信息列表
okCount
=
okCount
+
1
log
.
info
(
f
'{short_name}==============解析传输操作成功'
)
state
=
1
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
pdf_url
,
''
)
pass
else
:
errorCount
+=
1
# time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
log
.
error
(
f
'{short_name}=============解析或传输操作失败'
)
# try:
# insert_err_sql = f"insert into dt_err(xydm,`from`,url,title,pub_date,zhaiyao,create_date,state,pageNo,pageIndex,type) values('{social_code}','证监会','{pdf_url}','{name_pdf}','{pub_time}',' ',now(),1,{i},{pageIndex},'1')"
# cursor_.execute(insert_err_sql)
# cnx_.commit()
# except:
# pass
continue
Maxpage
=
int
(
total
)
//
15
+
1
log
.
info
(
f
'{short_name}====={code}===========一共{total}条,{Maxpage}页'
)
# 首页和其他页不同,遍历 如果是首页 修改一下链接
for
i
in
range
(
1
,
Maxpage
+
1
):
log
.
info
(
f
'==========正在采集第{i}页========='
)
if
i
==
1
:
href
=
url
else
:
# http://eid.csrc.gov.cn/101811/index_3_f.html
href
=
url
.
split
(
'index'
)[
0
]
+
f
'index_{i}_f.html'
soup
=
RequestUrl
(
href
,
payload
,
social_code
,
start_time
)
if
soup
==
''
:
continue
tr_list
=
soup
.
find
(
'div'
,
id
=
'txt'
)
.
find_all
(
'tr'
)
pageIndex
=
0
for
tr
in
tr_list
[
1
:]:
pageIndex
+=
1
td_list
=
tr
.
find_all
(
'td'
)
pdf_url_info
=
td_list
[
2
]
# print(pdf_url)
pdf_url
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
0
]
.
strip
(
'
\'
'
)
name_pdf
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
1
]
.
strip
(
'
\'
'
)
pub_time
=
pdf_url_info
[
'onclick'
]
.
strip
(
'downloadPdf1('
)
.
split
(
','
)[
2
]
.
strip
(
'
\'
'
)
year
=
pub_time
[:
4
]
report_type
=
td_list
[
4
]
.
text
.
strip
()
# 信息插入数据库
insert
=
InsterInto
(
short_name
,
social_code
,
name_pdf
,
pub_time
,
pdf_url
,
report_type
)
log
.
info
(
f
'======={short_name}========{code}===插入公告库成功'
)
if
insert
:
# # 公告信息列表
# okCount = okCount + 1
# 解析PDF内容,先获取PDF链接 下载 解析成功,解析失败 ,传输成功,传输失败
result
=
GetContent
(
pdf_url
,
name_pdf
,
social_code
,
year
,
pub_time
,
start_time
)
if
result
:
# 公告信息列表
okCount
=
okCount
+
1
log
.
info
(
f
'{short_name}==============解析传输操作成功'
)
state
=
1
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
pdf_url
,
''
)
pass
else
:
errorCount
+=
1
# time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
log
.
error
(
f
'{short_name}=============解析或传输操作失败'
)
# try:
# insert_err_sql = f"insert into dt_err(xydm,`from`,url,title,pub_date,zhaiyao,create_date,state,pageNo,pageIndex,type) values('{social_code}','证监会','{pdf_url}','{name_pdf}','{pub_time}',' ',now(),1,{i},{pageIndex},'1')"
# cursor_.execute(insert_err_sql)
# cnx_.commit()
# except:
# pass
continue
return
True
#state2
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论