Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
53ccb166
提交
53ccb166
authored
12月 07, 2023
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
政策法规脚本维护
上级
95d7e6b2
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
14 行删除
+24
-14
policy.py
comData/policylaw/policy.py
+24
-14
没有找到文件。
comData/policylaw/policy.py
浏览文件 @
53ccb166
...
@@ -36,7 +36,7 @@ taskType = '政策法规'
...
@@ -36,7 +36,7 @@ taskType = '政策法规'
各地方国资委
各地方国资委
"""
"""
db_storage
=
pymongo
.
MongoClient
(
'mongodb://114.115.221.202:27017'
,
username
=
'admin'
,
password
=
'
zzsn@9988'
)
.
caiji
[
db_storage
=
pymongo
.
MongoClient
(
'mongodb://114.115.221.202:27017'
,
username
=
'admin'
,
password
=
'
ZZsn@9988'
)
.
ZZSN
[
'国务院_国资委_copy1'
]
'国务院_国资委_copy1'
]
driver_path
=
r'D:\cmd100\chromedriver.exe'
driver_path
=
r'D:\cmd100\chromedriver.exe'
...
@@ -97,7 +97,8 @@ def save_data(dic_news):
...
@@ -97,7 +97,8 @@ def save_data(dic_news):
'tid'
:
dic_news
[
'labels'
][
0
][
'relationId'
],
'tid'
:
dic_news
[
'labels'
][
0
][
'relationId'
],
'来源'
:
dic_news
[
'labels'
][
0
][
'relationName'
],
'来源'
:
dic_news
[
'labels'
][
0
][
'relationName'
],
'创建时间'
:
dic_news
[
'createDate'
],
'创建时间'
:
dic_news
[
'createDate'
],
'带标签内容'
:
dic_news
[
'contentWithTag'
][:
100
]
'带标签内容'
:
dic_news
[
'contentWithTag'
][:
100
],
'发布时间'
:
dic_news
[
'publishDate'
]
}
}
db_storage
.
insert_one
(
aaa_dic
)
db_storage
.
insert_one
(
aaa_dic
)
...
@@ -1009,6 +1010,8 @@ def ji_lin():
...
@@ -1009,6 +1010,8 @@ def ji_lin():
else
:
else
:
pub
=
i_soup
.
find
(
class_
=
'share'
)
pub
=
i_soup
.
find
(
class_
=
'share'
)
pub_time
=
pub
.
find
(
class_
=
'left'
)
.
find
(
'span'
,
class_
=
'time'
)
.
text
pub_time
=
pub
.
find
(
class_
=
'left'
)
.
find
(
'span'
,
class_
=
'time'
)
.
text
if
'时间'
in
pub_time
:
pub_time
=
pub_time
.
split
(
'时间:'
)[
1
]
.
strip
()
pub_come
=
pub
.
find
(
class_
=
'right'
)
.
find
(
'span'
,
class_
=
'source'
)
.
text
.
split
(
'来源:'
)[
1
]
.
strip
()
pub_come
=
pub
.
find
(
class_
=
'right'
)
.
find
(
'span'
,
class_
=
'source'
)
.
text
.
split
(
'来源:'
)[
1
]
.
strip
()
# print(pub_come)
# print(pub_come)
i_content
=
soup
.
find
(
class_
=
'zsy_comain'
)
i_content
=
soup
.
find
(
class_
=
'zsy_comain'
)
...
@@ -2393,12 +2396,12 @@ def hai_nan():
...
@@ -2393,12 +2396,12 @@ def hai_nan():
i_href
=
str
(
i_href
)
.
replace
(
'../../'
,
'https://www.gov.cn/zhengce/'
)
i_href
=
str
(
i_href
)
.
replace
(
'../../'
,
'https://www.gov.cn/zhengce/'
)
try
:
try
:
try
:
try
:
is_href1
=
db_storage
.
find_one
({
'网址'
:
href
.
split
(
'?'
)[
0
]})
is_href1
=
db_storage
.
find_one
({
'网址'
:
i_
href
.
split
(
'?'
)[
0
]})
is_href2
=
db_storage
.
find_one
({
'网址'
:
href
})
is_href2
=
db_storage
.
find_one
({
'网址'
:
i_
href
})
except
:
except
:
is_href1
=
False
is_href1
=
False
is_href2
=
db_storage
.
find_one
({
'网址'
:
href
})
is_href2
=
db_storage
.
find_one
({
'网址'
:
i_
href
})
if
is_href1
or
is_href2
:
if
is_href1
or
is_href2
:
num
+=
1
num
+=
1
log
.
info
(
'已采集=====跳过'
)
log
.
info
(
'已采集=====跳过'
)
...
@@ -3966,7 +3969,14 @@ def shan_xi():
...
@@ -3966,7 +3969,14 @@ def shan_xi():
href
=
href
[
0
]
.
replace
(
'../../'
,
'http://gzw.shanxi.gov.cn/zxhrdgz/fzyd/zywj/'
)
.
replace
(
'./'
,
href
=
href
[
0
]
.
replace
(
'../../'
,
'http://gzw.shanxi.gov.cn/zxhrdgz/fzyd/zywj/'
)
.
replace
(
'./'
,
'http://gzw.shanxi.gov.cn/zxhrdgz/fzyd/zywj/'
)
'http://gzw.shanxi.gov.cn/zxhrdgz/fzyd/zywj/'
)
title
=
tr
.
xpath
(
'./td[1]/a/span//text()'
)[
0
]
title
=
tr
.
xpath
(
'./td[1]/a/span//text()'
)[
0
]
publishDate
=
tr
.
xpath
(
'./td[2]/span/text()'
)[
0
]
publishDate_
=
tr
.
xpath
(
'./td[2]/span/text()'
)[
0
]
pattern
=
r'\d{4}/\d{2}/\d{2}'
matched
=
re
.
findall
(
pattern
,
publishDate_
)
if
matched
:
date
=
pd
.
to_datetime
(
publishDate_
,
format
=
'
%
Y/
%
m/
%
d'
)
publishDate
=
date
.
strftime
(
'
%
Y-
%
m-
%
d'
)
else
:
publishDate
=
publishDate_
is_href
=
db_storage
.
find_one
({
'网址'
:
href
})
is_href
=
db_storage
.
find_one
({
'网址'
:
href
})
if
is_href
:
if
is_href
:
num
+=
1
num
+=
1
...
@@ -6238,14 +6248,14 @@ def hu_bei():
...
@@ -6238,14 +6248,14 @@ def hu_bei():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
#
get_content1()
get_content1
()
#
get_content3()
get_content3
()
#
bei_jing()
bei_jing
()
#
nei_meng_gu()
nei_meng_gu
()
#
ji_lin()
ji_lin
()
#
shang_hai()
shang_hai
()
#
zhe_jiang()
zhe_jiang
()
#
fu_jian()
fu_jian
()
shan_dong
()
shan_dong
()
guang_dong
()
guang_dong
()
hai_nan
()
hai_nan
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论