Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzsn_spider
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王景浩
zzsn_spider
Commits
184485c7
提交
184485c7
authored
1月 06, 2024
作者:
薛凌堃
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
24/01/06
上级
55610b8f
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
22 行增加
和
11 行删除
+22
-11
config.ini
google_comm/config.ini
+5
-4
googleSpider.py
google_comm/googleSpider.py
+10
-2
googletaskJob.py
google_comm/googletaskJob.py
+2
-2
config.ini
百度采集/baidu_comm/config.ini
+5
-3
没有找到文件。
google_comm/config.ini
浏览文件 @
184485c7
...
...
@@ -13,9 +13,10 @@ url=jdbc:mysql://114.115.159.144:3306/caiji?useUnicode=true&characterEncoding=ut
[kafka]
bootstrap_servers
=
114.115.159.144:9092
topic
=
keyWordsInfo
groupId
=
python_
baidu_test
groupId
=
python_
google
[selenium]
chrome_driver
=
C:
\U
sers
\W
IN10
\D
ataspellProjects
\c
rawlerProjectDemo
\t
mpcrawler
\c
md100
\c
hromedriver.exe
binary_location
=
D:
\c
rawler
\b
aidu_crawler
\t
ool
\G
oogle
\C
hrome
\A
pplication
\c
hrome.exe
;chrome_driver=C:\Users\WIN10\DataspellProjects\crawlerProjectDemo\tmpcrawler\cmd100\chromedriver.exe
;binary_location=D:\crawler\baidu_crawler\tool\Google\Chrome\Application\chrome.exe
chrome_driver
=
D:
\c
md100
\c
hromedriver.exe
binary_location
=
D:
\G
oogle
\C
hrome
\A
pplication
\c
hrome.exe
google_comm/googleSpider.py
浏览文件 @
184485c7
...
...
@@ -168,6 +168,8 @@ class GoogleSpider(object):
try
:
driver
.
get
(
url
)
# 等待页面加载完成
time
.
sleep
(
3
)
driver
.
refresh
()
wait
=
WebDriverWait
(
driver
,
20
)
wait
.
until
(
EC
.
presence_of_element_located
((
By
.
TAG_NAME
,
"body"
)))
html
=
driver
.
page_source
...
...
@@ -256,6 +258,7 @@ class GoogleSpider(object):
self
.
driver
.
get
(
self
.
url
)
# 等待页面加载完成
time
.
sleep
(
3
)
self
.
driver
.
refresh
()
wait
=
WebDriverWait
(
self
.
driver
,
20
)
wait
.
until
(
EC
.
presence_of_element_located
((
By
.
TAG_NAME
,
"body"
)))
search_input
=
self
.
driver
.
find_element
(
'xpath'
,
'//textarea[@title="Google 搜索"]'
)
...
...
@@ -265,7 +268,11 @@ class GoogleSpider(object):
time
.
sleep
(
3
)
wait
=
WebDriverWait
(
self
.
driver
,
20
)
wait
.
until
(
EC
.
presence_of_element_located
((
By
.
TAG_NAME
,
"body"
)))
try
:
self
.
driver
.
find_element
(
'xpath'
,
'//div[@class="GKS7s"]/span[text()="新闻"]'
)
.
click
()
except
:
self
.
driver
.
find_element
(
'xpath'
,
'//*[@id="hdtb-msb"]/div[1]/div/div[2]/a/span'
)
.
click
()
time
.
sleep
(
3
)
self
.
driver
.
find_element
(
'xpath'
,
'//div[@id="hdtb-tls"]'
)
.
click
()
time
.
sleep
(
2
)
...
...
@@ -273,7 +280,8 @@ class GoogleSpider(object):
time
.
sleep
(
2
)
self
.
driver
.
find_element
(
'xpath'
,
'//div[@class="YpcDnf OSrXXb HG1dvd"]/a[text()="按日期排序"]'
)
.
click
()
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
info
(
f
'--点击按钮失效----{e}'
)
return
self
.
logger
.
info
(
"开始抓取首页..."
+
self
.
searchkw
)
time
.
sleep
(
5
)
flag
,
lists
=
self
.
parse_page
()
...
...
@@ -446,7 +454,7 @@ class GoogleSpider(object):
detailurl
=
detailmsg
[
'detailUrl'
]
title
=
detailmsg
[
'title'
]
content
,
contentWithTag
=
self
.
extractorMsg
(
detailurl
,
title
)
contentWithTag
=
self
.
rmTagattr
(
contentWithTag
)
contentWithTag
=
self
.
rmTagattr
(
contentWithTag
,
detailurl
)
except
Exception
as
e
:
content
=
''
contentWithTag
=
''
...
...
google_comm/googletaskJob.py
浏览文件 @
184485c7
...
...
@@ -40,7 +40,7 @@ class GoogleTaskJob(object):
try
:
for
record
in
consumer
:
try
:
logger
.
info
(
"value:"
,
record
.
value
)
logger
.
info
(
f
"value:{record.value}"
)
keymsg
=
record
.
value
if
keymsg
:
break
...
...
@@ -176,7 +176,7 @@ if __name__ == '__main__':
continue
if
kwList
:
# 创建一个线程池,指定线程数量为4
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
2
)
as
executor
:
with
concurrent
.
futures
.
ThreadPoolExecutor
(
max_workers
=
1
)
as
executor
:
# 提交任务给线程池,每个任务处理一个数据
results
=
[
executor
.
submit
(
googleTaskJob
.
runSpider
,
data
)
for
data
in
kwList
]
# 获取任务的执行结果
...
...
百度采集/baidu_comm/config.ini
浏览文件 @
184485c7
[redi
s]
[redi
s]
...
...
@@ -16,6 +16,8 @@ topic=keyWordsInfo
groupId
=
python_baidu
[selenium]
chrome_driver
=
C:
\U
sers
\W
IN10
\D
ataspellProjects
\c
rawlerProjectDemo
\t
mpcrawler
\c
md100
\c
hromedriver.exe
binary_location
=
D:
\c
rawler
\b
aidu_crawler
\t
ool
\G
oogle
\C
hrome
\A
pplication
\c
hrome.exe
;chrome_driver=C:\Users\WIN10\DataspellProjects\crawlerProjectDemo\tmpcrawler\cmd100\chromedriver.exe
;binary_location=D:\crawler\baidu_crawler\tool\Google\Chrome\Application\chrome.exe
chrome_driver
=
D:
\c
md100
\c
hromedriver.exe
binary_location
=
D:
\G
oogle
\C
hrome
\A
pplication
\c
hrome.exe
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论