Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
632d5a17
提交
632d5a17
authored
2月 26, 2024
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
企业公告维护
上级
8cf6e366
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
26 行删除
+66
-26
东方财富网-公告.py
comData/noticeReport/东方财富网-公告.py
+29
-10
东方财富网-港股公告-2.py
comData/noticeReport/东方财富网-港股公告-2.py
+0
-0
东方财富网-港股公告.py
comData/noticeReport/东方财富网-港股公告.py
+37
-16
没有找到文件。
comData/noticeReport/东方财富网-公告.py
浏览文件 @
632d5a17
impor
t
os
impor
t
os
...
...
@@ -46,22 +46,41 @@ def uptoOBS(pdf_url,pdf_name,type_id,social_code):
'category'
:
category
,
'file_size'
:
''
,
'status'
:
1
,
'create_by'
:
'XueLingKun'
,
'create_time'
:
''
,
'page_size'
:
''
,
'content'
:
''
}
headers
[
'User-Agent'
]
=
baseCore
.
getRandomUserAgent
()
for
i
in
range
(
0
,
3
)
:
if
category
==
'.pdf'
:
try
:
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
timeout
=
20
)
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
timeout
=
20
)
if
response
.
status_code
!=
200
:
return
retData
file_size
=
int
(
response
.
headers
.
get
(
'Content-Length'
))
retData
[
'content'
]
=
response
.
text
#todo:判断内容是否成功
with
fitz
.
open
(
stream
=
response
.
content
,
filetype
=
'pdf'
)
as
doc
:
page_size
=
doc
.
page_count
for
page
in
doc
.
pages
():
retData
[
'content'
]
+=
page
.
get_text
()
# todo:判断内容是否成功
if
'<div class="K">403</div>'
in
retData
[
'content'
]
or
'Error Times: '
in
retData
[
'content'
]:
return
retData
else
:
break
pass
except
:
time
.
sleep
(
3
)
continue
page_size
=
1
log
.
error
(
f
'文件损坏'
)
return
retData
else
:
for
i
in
range
(
0
,
3
):
try
:
page_size
=
1
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
timeout
=
20
)
if
response
.
status_code
!=
200
:
return
retData
file_size
=
int
(
response
.
headers
.
get
(
'Content-Length'
))
retData
[
'content'
]
=
response
.
text
#todo:判断内容是否成功
if
'<div class="K">403</div>'
in
retData
[
'content'
]
or
'Error Times: '
in
retData
[
'content'
]:
return
retData
else
:
break
except
:
time
.
sleep
(
3
)
continue
name
=
str
(
getuuid
())
+
category
try
:
result
=
getOBSres
(
pathType
,
name
,
response
)
...
...
@@ -85,7 +104,7 @@ def uptoOBS(pdf_url,pdf_name,type_id,social_code):
except
Exception
as
e
:
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
pdf_url
,
f
'{e}'
)
#
baseCore.recordLog(social_code, taskType, state, takeTime, pdf_url, f'{e}')
return
retData
return
retData
...
...
comData/noticeReport/东方财富网-港股公告-2.py
0 → 100644
浏览文件 @
632d5a17
差异被折叠。
点击展开。
comData/noticeReport/东方财富网-港股公告.py
浏览文件 @
632d5a17
impor
t
os
impor
t
os
...
...
@@ -48,6 +48,7 @@ def getuuid():
get_timestamp_uuid
=
uuid
.
uuid1
()
# 根据 时间戳生成 uuid , 保证全球唯一
return
get_timestamp_uuid
def
uptoOBS
(
pdf_url
,
pdf_name
,
type_id
,
social_code
):
headers
=
{}
category
=
os
.
path
.
splitext
(
pdf_url
)[
1
]
...
...
@@ -56,16 +57,41 @@ def uptoOBS(pdf_url,pdf_name,type_id,social_code):
'category'
:
category
,
'file_size'
:
''
,
'status'
:
1
,
'create_by'
:
'XueLingKun'
,
'create_time'
:
''
,
'page_size'
:
''
,
'content'
:
''
}
headers
[
'User-Agent'
]
=
baseCore
.
getRandomUserAgent
()
for
i
in
range
(
0
,
3
)
:
if
category
==
'.pdf'
:
try
:
ip
=
baseCore
.
get_proxy
()
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
proxies
=
ip
,
timeout
=
20
)
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
timeout
=
20
)
if
response
.
status_code
!=
200
:
return
retData
file_size
=
int
(
response
.
headers
.
get
(
'Content-Length'
))
retData
[
'content'
]
=
response
.
text
break
except
Exception
as
e
:
time
.
sleep
(
60
)
continue
with
fitz
.
open
(
stream
=
response
.
content
,
filetype
=
'pdf'
)
as
doc
:
page_size
=
doc
.
page_count
for
page
in
doc
.
pages
():
retData
[
'content'
]
+=
page
.
get_text
()
# todo:判断内容是否成功
if
'<div class="K">403</div>'
in
retData
[
'content'
]
or
'Error Times: '
in
retData
[
'content'
]:
return
retData
else
:
pass
except
:
log
.
error
(
f
'文件损坏'
)
return
retData
else
:
for
i
in
range
(
0
,
3
):
try
:
page_size
=
1
response
=
requests
.
get
(
pdf_url
,
headers
=
headers
,
verify
=
False
,
timeout
=
20
)
if
response
.
status_code
!=
200
:
return
retData
file_size
=
int
(
response
.
headers
.
get
(
'Content-Length'
))
retData
[
'content'
]
=
response
.
text
#todo:判断内容是否成功
if
'<div class="K">403</div>'
in
retData
[
'content'
]
or
'Error Times: '
in
retData
[
'content'
]:
return
retData
else
:
break
except
:
time
.
sleep
(
3
)
continue
name
=
str
(
getuuid
())
+
category
try
:
...
...
@@ -73,12 +99,6 @@ def uptoOBS(pdf_url,pdf_name,type_id,social_code):
except
:
log
.
error
(
f
'OBS发送失败'
)
return
retData
try
:
with
fitz
.
open
(
stream
=
response
.
content
,
filetype
=
'pdf'
)
as
doc
:
page_size
=
doc
.
page_count
except
:
log
.
error
(
f
'文件损坏'
)
return
retData
if
page_size
<
1
:
# pdf解析失败
# print(f'======pdf解析失败=====')
...
...
@@ -95,11 +115,12 @@ def uptoOBS(pdf_url,pdf_name,type_id,social_code):
except
Exception
as
e
:
state
=
0
takeTime
=
baseCore
.
getTimeCost
(
start_time
,
time
.
time
())
baseCore
.
recordLog
(
social_code
,
taskType
,
state
,
takeTime
,
pdf_url
,
f
'{e}'
)
#
baseCore.recordLog(social_code, taskType, state, takeTime, pdf_url, f'{e}')
return
retData
return
retData
@retry
(
tries
=
3
,
delay
=
1
)
def
getOBSres
(
pathType
,
name
,
response
):
result
=
obsClient
.
putContent
(
'zzsn'
,
pathType
+
name
,
content
=
response
.
content
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论