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
b71f3795
Commit
b71f3795
authored
Mar 18, 2017
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a7f9e7ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
Site.java
webmagic-core/src/main/java/us/codecraft/webmagic/Site.java
+0
-4
TimerReuseProxyPool.java
...java/us/codecraft/webmagic/proxy/TimerReuseProxyPool.java
+7
-7
No files found.
webmagic-core/src/main/java/us/codecraft/webmagic/Site.java
View file @
b71f3795
...
...
@@ -513,8 +513,4 @@ public class Site {
return
httpProxyPool
.
getProxy
();
}
public
void
returnHttpProxyToPool
(
HttpHost
proxy
,
int
statusCode
)
{
httpProxyPool
.
returnProxy
(
proxy
,
statusCode
);
}
}
webmagic-core/src/main/java/us/codecraft/webmagic/proxy/TimerReuseProxyPool.java
View file @
b71f3795
...
...
@@ -186,31 +186,31 @@ public class TimerReuseProxyPool implements ProxyPool {
}
public
void
returnProxy
(
HttpHost
host
,
int
statusCode
)
{
Proxy
p
=
allProxy
.
get
(
host
.
getAddress
().
getHostAddress
());
TimerReuse
Proxy
p
=
allProxy
.
get
(
host
.
getAddress
().
getHostAddress
());
if
(
p
==
null
)
{
return
;
}
switch
(
statusCode
)
{
case
Proxy
.
SUCCESS
:
case
TimerReuse
Proxy
.
SUCCESS
:
p
.
setReuseTimeInterval
(
reuseInterval
);
p
.
setFailedNum
(
0
);
p
.
setFailedErrorType
(
new
ArrayList
<
Integer
>());
p
.
recordResponse
();
p
.
successNumIncrement
(
1
);
break
;
case
Proxy
.
ERROR_403
:
case
TimerReuse
Proxy
.
ERROR_403
:
// banned,try longer interval
p
.
fail
(
Proxy
.
ERROR_403
);
p
.
fail
(
TimerReuse
Proxy
.
ERROR_403
);
p
.
setReuseTimeInterval
(
reuseInterval
*
p
.
getFailedNum
());
logger
.
info
(
host
+
" >>>> reuseTimeInterval is >>>> "
+
p
.
getReuseTimeInterval
()
/
1000.0
);
break
;
case
Proxy
.
ERROR_BANNED
:
p
.
fail
(
Proxy
.
ERROR_BANNED
);
case
TimerReuse
Proxy
.
ERROR_BANNED
:
p
.
fail
(
TimerReuse
Proxy
.
ERROR_BANNED
);
p
.
setReuseTimeInterval
(
10
*
60
*
1000
*
p
.
getFailedNum
());
logger
.
warn
(
"this proxy is banned >>>> "
+
p
.
getHttpHost
());
logger
.
info
(
host
+
" >>>> reuseTimeInterval is >>>> "
+
p
.
getReuseTimeInterval
()
/
1000.0
);
break
;
case
Proxy
.
ERROR_404
:
case
TimerReuse
Proxy
.
ERROR_404
:
// p.fail(Proxy.ERROR_404);
// p.setReuseTimeInterval(reuseInterval * p.getFailedNum());
break
;
...
...
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