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
75198f00
Commit
75198f00
authored
May 11, 2018
by
shenjunlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代理
parent
24563aff
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
29 deletions
+33
-29
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
+26
-22
pom.xml
webmagic-extension/pom.xml
+1
-1
Data5UProxyProvider.java
...java/us/codecraft/webmagic/proxy/Data5UProxyProvider.java
+1
-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 @
75198f00
...
...
@@ -6,7 +6,7 @@
<version>
7
</version>
</parent>
<groupId>
us.codecraft.duiba
</groupId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-SNAPSHOT
</version>
<modelVersion>
4.0.0
</modelVersion>
<packaging>
pom
</packaging>
<properties>
...
...
webmagic-core/pom.xml
View file @
75198f00
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/Spider.java
View file @
75198f00
...
...
@@ -306,29 +306,33 @@ public class Spider implements Runnable, Task {
logger
.
info
(
"Spider {} started!"
,
getUUID
());
while
(!
Thread
.
currentThread
().
isInterrupted
()
&&
stat
.
get
()
==
STAT_RUNNING
)
{
//while (!Thread.interrupted() && stat.get() == STAT_RUNNING) {
final
Request
request
=
scheduler
.
poll
(
this
);
if
(
request
==
null
)
{
if
(
threadPool
.
getThreadAlive
()
==
0
&&
exitWhenComplete
)
{
break
;
}
// wait until new url added
waitNewUrl
();
}
else
{
threadPool
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
processRequest
(
request
);
onSuccess
(
request
);
}
catch
(
Exception
e
)
{
onError
(
request
);
logger
.
error
(
"process request "
+
request
+
" error"
,
e
);
}
finally
{
pageCount
.
incrementAndGet
();
signalNewUrl
();
}
try
{
final
Request
request
=
scheduler
.
poll
(
this
);
if
(
request
==
null
)
{
if
(
threadPool
.
getThreadAlive
()
==
0
&&
exitWhenComplete
)
{
break
;
}
});
// wait until new url added
waitNewUrl
();
}
else
{
threadPool
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
processRequest
(
request
);
onSuccess
(
request
);
}
catch
(
Exception
e
)
{
onError
(
request
);
logger
.
error
(
"process request "
+
request
+
" error"
,
e
);
}
finally
{
pageCount
.
incrementAndGet
();
signalNewUrl
();
}
}
});
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
stat
.
set
(
STAT_STOPPED
);
...
...
webmagic-extension/pom.xml
View file @
75198f00
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-extension/src/main/java/us/codecraft/webmagic/proxy/Data5UProxyProvider.java
View file @
75198f00
...
...
@@ -22,7 +22,7 @@ public class Data5UProxyProvider implements ProxyProvider{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
static
Cache
<
String
,
Proxy
>
proxyCache
=
CacheBuilder
.
newBuilder
()
.
expireAfterWrite
(
30
,
TimeUnit
.
SECONDS
)
//20
秒过期,Data5u提供的代理有1分钟过期,2分钟过期,5分钟过期
.
expireAfterWrite
(
5
,
TimeUnit
.
SECONDS
)
//5
秒过期,Data5u提供的代理有1分钟过期,2分钟过期,5分钟过期
.
maximumSize
(
10
).
build
();
private
String
data5UApiUrl
;
...
...
webmagic-samples/pom.xml
View file @
75198f00
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-saxon/pom.xml
View file @
75198f00
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
webmagic-scripts/pom.xml
View file @
75198f00
...
...
@@ -3,7 +3,7 @@
<parent>
<groupId>
us.codecraft.duiba
</groupId>
<artifactId>
webmagic-parent
</artifactId>
<version>
0.
8.8
-SNAPSHOT
</version>
<version>
0.
9.0
-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