Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ssssssss-team
spider-flow
提交
445d4045
S
spider-flow
项目概览
ssssssss-team
/
spider-flow
10 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spider-flow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
445d4045
编写于
6月 06, 2022
作者:
N
nekolr
提交者:
GitHub
6月 06, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #33 from everydoc/master
add crawl copy
上级
a75b1548
8b4e4902
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
37 deletion
+71
-37
spider-flow-core/src/main/java/org/spiderflow/core/service/SpiderFlowService.java
...n/java/org/spiderflow/core/service/SpiderFlowService.java
+19
-12
spider-flow-web/src/main/java/org/spiderflow/controller/SpiderFlowController.java
.../java/org/spiderflow/controller/SpiderFlowController.java
+28
-23
spider-flow-web/src/main/resources/static/spiderList.html
spider-flow-web/src/main/resources/static/spiderList.html
+24
-2
未找到文件。
spider-flow-core/src/main/java/org/spiderflow/core/service/SpiderFlowService.java
浏览文件 @
445d4045
...
...
@@ -35,13 +35,13 @@ import java.util.stream.Collectors;
*/
@Service
public
class
SpiderFlowService
extends
ServiceImpl
<
SpiderFlowMapper
,
SpiderFlow
>
{
@Autowired
private
SpiderFlowMapper
sfMapper
;
@Autowired
private
SpiderJobManager
spiderJobManager
;
@Autowired
private
FlowNoticeMapper
flowNoticeMapper
;
...
...
@@ -73,15 +73,15 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
public
IPage
<
SpiderFlow
>
selectSpiderPage
(
Page
<
SpiderFlow
>
page
,
String
name
){
return
sfMapper
.
selectSpiderPage
(
page
,
name
);
}
public
int
executeCountIncrement
(
String
id
,
Date
lastExecuteTime
,
Date
nextExecuteTime
){
if
(
nextExecuteTime
==
null
){
return
sfMapper
.
executeCountIncrement
(
id
,
lastExecuteTime
);
}
return
sfMapper
.
executeCountIncrementAndExecuteTime
(
id
,
lastExecuteTime
,
nextExecuteTime
);
}
/**
* 重置定时任务
* @param id 爬虫的ID
...
...
@@ -130,13 +130,20 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
}
return
true
;
}
public
void
stop
(
String
id
){
sfMapper
.
resetSpiderStatus
(
id
,
"0"
);
sfMapper
.
resetNextExecuteTime
(
id
);
spiderJobManager
.
remove
(
id
);
}
public
void
copy
(
String
id
){
// 复制ID
SpiderFlow
spiderFlow
=
sfMapper
.
selectById
(
id
);
String
new_id
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
sfMapper
.
insertSpiderFlow
(
new_id
,
spiderFlow
.
getName
()
+
"-copy"
,
spiderFlow
.
getXml
());
}
public
void
start
(
String
id
){
spiderJobManager
.
remove
(
id
);
SpiderFlow
spiderFlow
=
getById
(
id
);
...
...
@@ -147,11 +154,11 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
sfMapper
.
resetSpiderStatus
(
id
,
"1"
);
}
}
public
void
run
(
String
id
){
spiderJobManager
.
run
(
id
);
}
public
void
resetExecuteCount
(
String
id
){
sfMapper
.
resetExecuteCount
(
id
);
}
...
...
@@ -160,11 +167,11 @@ public class SpiderFlowService extends ServiceImpl<SpiderFlowMapper, SpiderFlow>
spiderJobManager
.
remove
(
id
);
flowNoticeMapper
.
deleteById
(
id
);
}
public
List
<
SpiderFlow
>
selectOtherFlows
(
String
id
){
return
sfMapper
.
selectOtherFlows
(
id
);
}
public
List
<
SpiderFlow
>
selectFlows
(){
return
sfMapper
.
selectFlows
();
}
...
...
spider-flow-web/src/main/java/org/spiderflow/controller/SpiderFlowController.java
浏览文件 @
445d4045
...
...
@@ -48,29 +48,29 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping
(
"/spider"
)
public
class
SpiderFlowController
{
@Autowired
private
List
<
FunctionExecutor
>
functionExecutors
;
@Autowired
private
List
<
FunctionExtension
>
functionExtensions
;
@Autowired
private
List
<
Grammerable
>
grammerables
;
@Autowired
private
SpiderFlowService
spiderFlowService
;
@Autowired
(
required
=
false
)
private
List
<
PluginConfig
>
pluginConfigs
;
@Value
(
"${spider.workspace}"
)
private
String
workspace
;
private
final
List
<
Grammer
>
grammers
=
new
ArrayList
<
Grammer
>();
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SpiderFlowController
.
class
);
@PostConstruct
private
void
init
(){
for
(
FunctionExecutor
executor
:
functionExecutors
)
{
...
...
@@ -84,7 +84,7 @@ public class SpiderFlowController {
grammer
.
setFunction
(
function
);
grammers
.
add
(
grammer
);
}
for
(
FunctionExtension
extension
:
functionExtensions
)
{
String
owner
=
extension
.
support
().
getSimpleName
();
grammers
.
addAll
(
Grammer
.
findGrammers
(
extension
.
getClass
(),
null
,
owner
,
true
));
...
...
@@ -93,7 +93,7 @@ public class SpiderFlowController {
grammers
.
addAll
(
grammerable
.
grammers
());
}
}
/**
* 爬虫列表
* @param page 页数
...
...
@@ -104,7 +104,7 @@ public class SpiderFlowController {
public
IPage
<
SpiderFlow
>
list
(
@RequestParam
(
name
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
name
=
"limit"
,
defaultValue
=
"1"
)
Integer
size
,
@RequestParam
(
name
=
"name"
,
defaultValue
=
""
)
String
name
)
{
return
spiderFlowService
.
selectSpiderPage
(
new
Page
<>(
page
,
size
),
name
);
}
@RequestMapping
(
"/save"
)
public
String
save
(
SpiderFlow
spiderFlow
){
spiderFlowService
.
save
(
spiderFlow
);
...
...
@@ -119,12 +119,12 @@ public class SpiderFlowController {
return
new
JsonBean
<>(
spiderFlowService
.
historyList
(
id
));
}
}
@RequestMapping
(
"/get"
)
public
SpiderFlow
get
(
String
id
){
return
spiderFlowService
.
getById
(
id
);
}
@RequestMapping
(
"/other"
)
public
List
<
SpiderFlow
>
other
(
String
id
){
if
(
StringUtils
.
isBlank
(
id
)){
...
...
@@ -132,32 +132,37 @@ public class SpiderFlowController {
}
return
spiderFlowService
.
selectOtherFlows
(
id
);
}
@RequestMapping
(
"/remove"
)
public
void
remove
(
String
id
){
spiderFlowService
.
remove
(
id
);
}
@RequestMapping
(
"/start"
)
public
void
start
(
String
id
){
spiderFlowService
.
start
(
id
);
}
@RequestMapping
(
"/stop"
)
public
void
stop
(
String
id
){
spiderFlowService
.
stop
(
id
);
}
@RequestMapping
(
"/copy"
)
public
void
copy
(
String
id
){
spiderFlowService
.
copy
(
id
);
}
@RequestMapping
(
"/run"
)
public
void
run
(
String
id
){
spiderFlowService
.
run
(
id
);
}
@RequestMapping
(
"/cron"
)
public
void
cron
(
String
id
,
String
cron
){
spiderFlowService
.
resetCornExpression
(
id
,
cron
);
}
@RequestMapping
(
"/xml"
)
public
String
xml
(
String
id
){
return
spiderFlowService
.
getById
(
id
).
getXml
();
...
...
@@ -192,17 +197,17 @@ public class SpiderFlowController {
return
new
JsonBean
<>(-
1
,
"读取日志文件出错"
);
}
}
@RequestMapping
(
"/shapes"
)
public
List
<
Shape
>
shapes
(){
return
ExecutorsUtils
.
shapes
();
}
@RequestMapping
(
"/pluginConfigs"
)
public
List
<
Plugin
>
pluginConfigs
(){
return
null
==
pluginConfigs
?
Collections
.
emptyList
()
:
pluginConfigs
.
stream
().
filter
(
e
->
e
.
plugin
()
!=
null
).
map
(
plugin
->
plugin
.
plugin
()).
collect
(
Collectors
.
toList
());
}
@RequestMapping
(
"/grammers"
)
public
JsonBean
<
List
<
Grammer
>>
grammers
(){
return
new
JsonBean
<>(
this
.
grammers
);
...
...
spider-flow-web/src/main/resources/static/spiderList.html
浏览文件 @
445d4045
...
...
@@ -84,7 +84,7 @@
align
:
'
center
'
},{
title
:
'
操作
'
,
width
:
195
,
width
:
250
,
align
:
'
center
'
,
templet
:
'
#buttons
'
}]]
...
...
@@ -121,6 +121,28 @@
}
$
(
"
body
"
).
on
(
'
click
'
,
'
.btn-search
'
,
function
(){
reloadTable
();
}).
on
(
'
click
'
,
'
.btn-copy
'
,
function
(){
var
id
=
$
(
this
).
data
(
'
id
'
);
layui
.
layer
.
confirm
(
'
您确定要复制此爬虫吗?
'
,{
title
:
'
复制
'
},
function
(
index
){
$table
.
reload
();
$
.
ajax
({
url
:
'
spider/copy
'
,
data
:
{
id
:
id
},
success
:
function
(){
layui
.
layer
.
msg
(
'
复制成功
'
,{
time
:
500
},
function
(){
$table
.
reload
();
})
},
error
:
function
(){
layui
.
layer
.
msg
(
'
复制失败
'
)
}
})
layui
.
layer
.
close
(
index
);
})
}).
on
(
'
click
'
,
'
.btn-remove
'
,
function
(){
var
id
=
$
(
this
).
data
(
'
id
'
);
layui
.
layer
.
confirm
(
'
您确定要删除此爬虫吗?
'
,{
...
...
@@ -205,4 +227,4 @@
<
a
class
=
"
layui-btn layui-btn-sm btn-remove
"
data
-
id
=
"
{{d.id}}
"
title
=
"
删除
"
><
i
class
=
"
layui-icon
"
>&
#
xe640
;
<
/i></
a
>
</script>
</body>
</html>
\ No newline at end of file
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录