Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
3ad4b1e5
提交
3ad4b1e5
authored
11月 29, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
11.29
上级
5d788bc9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
163 行增加
和
22 行删除
+163
-22
reits.py
REITs专题数据/reits.py
+0
-0
deletebyid.py
comData/YanBao/deletebyid.py
+5
-2
get_doc_id.py
comData/YanBao/get_doc_id.py
+134
-0
updateyear.py
comData/annualReport1023/updateyear.py
+3
-2
东方财富网-港股公告.py
comData/noticeReport/东方财富网-港股公告.py
+5
-2
BaseCore.py
comData/policylaw/BaseCore.py
+16
-16
policy.py
comData/policylaw/policy.py
+0
-0
没有找到文件。
REITs专题数据/reits.py
浏览文件 @
3ad4b1e5
差异被折叠。
点击展开。
comData/YanBao/deletebyid.py
浏览文件 @
3ad4b1e5
...
@@ -32,7 +32,7 @@ class EsMethod(object):
...
@@ -32,7 +32,7 @@ class EsMethod(object):
def
__init__
(
self
):
def
__init__
(
self
):
# 创建Elasticsearch对象,并提供账号信息
# 创建Elasticsearch对象,并提供账号信息
self
.
es
=
Elasticsearch
([
'http://114.116.19.92:9700'
],
http_auth
=
(
'elastic'
,
'zzsn9988'
),
timeout
=
300
)
self
.
es
=
Elasticsearch
([
'http://114.116.19.92:9700'
],
http_auth
=
(
'elastic'
,
'zzsn9988'
),
timeout
=
300
)
self
.
index_name
=
'
researchreportdata
'
self
.
index_name
=
'
policy
'
'''
'''
删除
删除
...
@@ -52,7 +52,10 @@ if __name__ == "__main__":
...
@@ -52,7 +52,10 @@ if __name__ == "__main__":
if
item
:
if
item
:
log
.
info
(
item
)
log
.
info
(
item
)
id
=
item
.
decode
()
id
=
item
.
decode
()
esMethod
.
delete
(
esMethod
.
index_name
,
id
)
try
:
esMethod
.
delete
(
esMethod
.
index_name
,
id
)
except
:
continue
else
:
else
:
log
.
info
(
'已删除完毕'
)
log
.
info
(
'已删除完毕'
)
break
break
...
...
comData/YanBao/get_doc_id.py
0 → 100644
浏览文件 @
3ad4b1e5
import
json
import
threading
import
time
import
uuid
import
redis
import
requests
from
retry
import
retry
from
elasticsearch
import
Elasticsearch
from
base
import
BaseCore
from
obs
import
ObsClient
import
fitz
from
urllib.parse
import
unquote
baseCore
=
BaseCore
.
BaseCore
()
log
=
baseCore
.
getLogger
()
baseCore
=
BaseCore
.
BaseCore
()
# 使用连接池
# cnx_ = baseCore.pool_11.connection()
# cursor_ = cnx_.cursor()
cnx_
=
baseCore
.
cnx_
cursor_
=
cnx_
.
cursor
()
lock
=
threading
.
Lock
()
pathType
=
'QYNotice/'
taskType
=
'企业研报/东方财富网'
pool
=
redis
.
ConnectionPool
(
host
=
"114.115.236.206"
,
port
=
6379
,
password
=
'clbzzsn'
,
db
=
6
)
class
EsMethod
(
object
):
def
__init__
(
self
):
# 创建Elasticsearch对象,并提供账号信息
self
.
es
=
Elasticsearch
([
'http://114.116.19.92:9700'
],
http_auth
=
(
'elastic'
,
'zzsn9988'
),
timeout
=
300
)
self
.
index_name
=
'policy'
def
queryatt
(
self
,
index_name
,
pnum
):
body
=
{
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"sid.keyword"
:
{
"value"
:
"1697458829758697473"
}
}
},
{
"range"
:
{
"createDate"
:
{
"gte"
:
"2023-11-28T10:00:00"
,
"lte"
:
"2023-11-29T10:00:00"
}
}
}
]
}
},
"track_total_hits"
:
True
,
"size"
:
200
,
"from"
:
pnum
}
filter_path
=
[
'hits.hits._id'
,
'hits.total.value'
,
'hits.hits._source.title'
,
'hits.hits._source.sourceAddress'
,
'hits.hits._source.createDate'
,
]
# 字段2
result
=
self
.
es
.
search
(
index
=
index_name
,
doc_type
=
'_doc'
,
filter_path
=
filter_path
,
body
=
body
)
# log.info(result)
return
result
def
main
(
page
,
p
,
esMethod
):
redis_conn
=
redis
.
Redis
(
connection_pool
=
pool
)
result
=
esMethod
.
queryatt
(
index_name
=
esMethod
.
index_name
,
pnum
=
p
)
total
=
result
[
'hits'
][
'total'
][
'value'
]
if
total
==
0
:
log
.
info
(
'++++已没有数据+++++'
)
return
msglist
=
result
[
'hits'
][
'hits'
]
log
.
info
(
f
'---第{page}页{len(msglist)}条数据----共{total}条数据----'
)
for
mms
in
msglist
:
id
=
mms
[
'_id'
]
title
=
mms
[
'_source'
][
'title'
]
sourceAddress
=
mms
[
'_source'
][
'sourceAddress'
]
log
.
info
(
f
'{id}--{title}--{sourceAddress}---'
)
if
redis_conn
.
lrem
(
'YanBao:id'
,
0
,
id
)
==
0
:
redis_conn
.
lpush
(
'YanBao:id'
,
id
)
else
:
continue
def
run_threads
(
num_threads
,
esMethod
,
j
):
threads
=
[]
for
i
in
range
(
num_threads
):
page
=
j
+
i
+
1
p
=
j
+
i
*
200
thread
=
threading
.
Thread
(
target
=
main
,
args
=
(
page
,
p
,
esMethod
))
threads
.
append
(
thread
)
thread
.
start
()
for
thread
in
threads
:
thread
.
join
()
if
__name__
==
"__main__"
:
j
=
0
for
i
in
range
(
5
):
esMethod
=
EsMethod
()
# result = esMethod.queryatt(index_name=esMethod.index_name, pnum=p)
# total = result['hits']['total']['value']
# if total == 0:
# log.info('++++已没有数据+++++')
# break
start
=
time
.
time
()
num_threads
=
5
run_threads
(
num_threads
,
esMethod
,
j
)
j
+=
1000
log
.
info
(
f
'5线程 每个处理200条数据 总耗时{time.time() - start}秒'
)
\ No newline at end of file
comData/annualReport1023/updateyear.py
浏览文件 @
3ad4b1e5
...
@@ -84,14 +84,15 @@ if __name__ == "__main__":
...
@@ -84,14 +84,15 @@ if __name__ == "__main__":
id_
=
redis_conn
.
lpop
(
'YanBao:up'
)
id_
=
redis_conn
.
lpop
(
'YanBao:up'
)
# id = "23112104300"
# id = "23112104300"
if
id
:
if
id
_
:
pass
pass
else
:
else
:
log
.
info
(
'已无数据'
)
log
.
info
(
'已无数据'
)
break
id
=
id_
.
decode
()
id
=
id_
.
decode
()
result_
=
esMethod
.
queryatt
(
index_name
=
esMethod
.
index_name
,
id
=
id
)
result_
=
esMethod
.
queryatt
(
index_name
=
esMethod
.
index_name
,
id
=
id
)
result
=
result_
[
'hits'
][
'hits'
][
0
]
result
=
result_
[
'hits'
][
'hits'
][
0
]
num
=
0
num
=
0
publishDate
=
result
[
'_source'
][
'publishDate'
]
publishDate
=
result
[
'_source'
][
'publishDate'
]
u_publishDate
=
'202
3-08
-31'
#+ publishDate.split('T')[1]
u_publishDate
=
'202
2-12
-31'
#+ publishDate.split('T')[1]
esMethod
.
updateaunn
(
esMethod
.
index_name
,
str
(
id
),
u_publishDate
)
esMethod
.
updateaunn
(
esMethod
.
index_name
,
str
(
id
),
u_publishDate
)
comData/noticeReport/东方财富网-港股公告.py
浏览文件 @
3ad4b1e5
impor
t
os
impor
t
os
...
@@ -323,7 +323,10 @@ def spider(browser, code, social_code, com_name):
...
@@ -323,7 +323,10 @@ def spider(browser, code, social_code, com_name):
# span_tag = browser.find_element(By.CLASS_NAME,'mbox')
# span_tag = browser.find_element(By.CLASS_NAME,'mbox')
span_tag
=
browser
.
find_element
(
By
.
XPATH
,
'//div[@class="mbox"]/span[2]'
)
span_tag
=
browser
.
find_element
(
By
.
XPATH
,
'//div[@class="mbox"]/span[2]'
)
current_page
=
int
(
span_tag
.
text
)
current_page
=
int
(
span_tag
.
text
)
totalpage
=
int
(
soup
.
find_all
(
'div'
,
class_
=
'mbox'
)[
-
1
]
.
find_all
(
'a'
)[
-
1
]
.
text
)
try
:
totalpage
=
int
(
soup
.
find_all
(
'div'
,
class_
=
'mbox'
)[
-
1
]
.
find_all
(
'a'
)[
-
1
]
.
text
)
except
:
totalpage
=
int
(
soup
.
find_all
(
'div'
,
class_
=
'mbox'
)[
-
1
]
.
find_all
(
'a'
)[
-
2
]
.
text
)
if
current_page
<
totalpage
:
if
current_page
<
totalpage
:
# 说明还未到最后一页
# 说明还未到最后一页
span_tag
.
find_element
(
By
.
XPATH
,
'./following-sibling::a[1]'
)
.
click
()
span_tag
.
find_element
(
By
.
XPATH
,
'./following-sibling::a[1]'
)
.
click
()
...
...
comData/policylaw/BaseCore.py
浏览文件 @
3ad4b1e5
...
@@ -508,7 +508,7 @@ class BaseCore:
...
@@ -508,7 +508,7 @@ class BaseCore:
except
:
except
:
time
.
sleep
(
3
)
time
.
sleep
(
3
)
continue
continue
page_size
=
0
#
page_size = 0
for
i
in
range
(
0
,
3
):
for
i
in
range
(
0
,
3
):
try
:
try
:
# name = file_name
# name = file_name
...
@@ -522,23 +522,23 @@ class BaseCore:
...
@@ -522,23 +522,23 @@ class BaseCore:
time
.
sleep
(
3
)
time
.
sleep
(
3
)
continue
continue
if
page_size
<
1
:
# if page_size < 1:
# pdf解析失败
# # pdf解析失败
# print(f'======pdf解析失败=====')
# # print(f'======pdf解析失败=====')
# return retData
# else:
try
:
time_now
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
retData
[
'state'
]
=
True
retData
[
'path'
]
=
result
[
'body'
][
'objectUrl'
]
.
split
(
'.com'
)[
1
]
retData
[
'full_path'
]
=
unquote
(
result
[
'body'
][
'objectUrl'
])
retData
[
'file_size'
]
=
self
.
convert_size
(
file_size
)
retData
[
'create_time'
]
=
time_now
except
Exception
as
e
:
print
(
f
'error:{e}'
)
return
retData
return
retData
else
:
try
:
time_now
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
retData
[
'state'
]
=
True
retData
[
'path'
]
=
result
[
'body'
][
'objectUrl'
]
.
split
(
'.com'
)[
1
]
retData
[
'full_path'
]
=
unquote
(
result
[
'body'
][
'objectUrl'
])
retData
[
'file_size'
]
=
self
.
convert_size
(
file_size
)
retData
[
'create_time'
]
=
time_now
except
Exception
as
e
:
print
(
f
'error:{e}'
)
return
retData
return
retData
return
retData
...
...
comData/policylaw/policy.py
浏览文件 @
3ad4b1e5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论