Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webmagic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
webmagic
Commits
15cea085
Commit
15cea085
authored
Mar 30, 2018
by
shenjunlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
6535928d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
8 deletions
+25
-8
pom.xml
pom.xml
+1
-1
pom.xml
webmagic-core/pom.xml
+1
-1
Spider.java
...agic-core/src/main/java/us/codecraft/webmagic/Spider.java
+1
-1
pom.xml
webmagic-extension/pom.xml
+1
-1
RedisScheduler.java
.../java/us/codecraft/webmagic/scheduler/RedisScheduler.java
+18
-1
pom.xml
webmagic-samples/pom.xml
+1
-1
pom.xml
webmagic-saxon/pom.xml
+1
-1
pom.xml
webmagic-scripts/pom.xml
+1
-1
No files found.
pom.xml
View file @
15cea085
...
...
@@ -6,7 +6,7 @@
<version>
7
</version>
</parent>
<groupId>
us.codecraft.duiba
</groupId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
pom
</packaging>
<properties>
...
...
webmagic-core/pom.xml
View file @
15cea085
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/Spider.java
View file @
15cea085
...
...
@@ -382,7 +382,7 @@ public class Spider implements Runnable, Task {
try
{
((
Closeable
)
object
).
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
...
...
webmagic-extension/pom.xml
View file @
15cea085
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-extension/src/main/java/us/codecraft/webmagic/scheduler/RedisScheduler.java
View file @
15cea085
...
...
@@ -10,13 +10,16 @@ import us.codecraft.webmagic.Request;
import
us.codecraft.webmagic.Task
;
import
us.codecraft.webmagic.scheduler.component.DuplicateRemover
;
import
java.io.Closeable
;
import
java.io.IOException
;
/**
* Use Redis as url scheduler for distributed crawlers.<br>
*
* @author code4crafter@gmail.com <br>
* @since 0.2.0
*/
public
class
RedisScheduler
extends
DuplicateRemovedScheduler
implements
MonitorableScheduler
,
DuplicateRemover
{
public
class
RedisScheduler
extends
DuplicateRemovedScheduler
implements
MonitorableScheduler
,
DuplicateRemover
,
Closeable
{
protected
JedisPool
pool
;
...
...
@@ -26,6 +29,8 @@ public class RedisScheduler extends DuplicateRemovedScheduler implements Monitor
private
static
final
String
ITEM_PREFIX
=
"item_"
;
private
Task
task
;
public
RedisScheduler
(
String
host
)
{
this
(
new
JedisPool
(
new
JedisPoolConfig
(),
host
));
}
...
...
@@ -47,6 +52,9 @@ public class RedisScheduler extends DuplicateRemovedScheduler implements Monitor
@Override
public
boolean
isDuplicate
(
Request
request
,
Task
task
)
{
if
(
this
.
task
==
null
)
{
this
.
task
=
task
;
}
Jedis
jedis
=
pool
.
getResource
();
try
{
return
jedis
.
sadd
(
getSetKey
(
task
),
request
.
getUrl
())
==
0
;
...
...
@@ -153,4 +161,13 @@ public class RedisScheduler extends DuplicateRemovedScheduler implements Monitor
pool
.
returnResource
(
jedis
);
}
}
@Override
public
void
close
()
throws
IOException
{
if
(
this
.
task
!=
null
)
{
this
.
resetDuplicateCheck
(
task
);
}
else
{
logger
.
error
(
"close redis scheduler error, task is null"
);
}
}
}
webmagic-samples/pom.xml
View file @
15cea085
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-saxon/pom.xml
View file @
15cea085
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-scripts/pom.xml
View file @
15cea085
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.8.
1
-SNAPSHOT
</version>
<version>
0.8.
2
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment