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
25821c3c
Commit
25821c3c
authored
May 08, 2016
by
yihua.huang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'EdwardsBean-proxy-strategy'
parents
b5413368
61c28a01
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
322 additions
and
314 deletions
+322
-314
Site.java
webmagic-core/src/main/java/us/codecraft/webmagic/Site.java
+5
-9
Proxy.java
...core/src/main/java/us/codecraft/webmagic/proxy/Proxy.java
+1
-1
ProxyPool.java
.../src/main/java/us/codecraft/webmagic/proxy/ProxyPool.java
+5
-303
SimpleProxyPool.java
...ain/java/us/codecraft/webmagic/proxy/SimpleProxyPool.java
+310
-0
ProxyTest.java
.../src/test/java/us/codecraft/webmagic/proxy/ProxyTest.java
+1
-1
No files found.
webmagic-core/src/main/java/us/codecraft/webmagic/Site.java
View file @
25821c3c
...
...
@@ -5,6 +5,7 @@ import com.google.common.collect.Table;
import
org.apache.http.HttpHost
;
import
us.codecraft.webmagic.proxy.Proxy
;
import
us.codecraft.webmagic.proxy.SimpleProxyPool
;
import
us.codecraft.webmagic.proxy.ProxyPool
;
import
us.codecraft.webmagic.utils.UrlUtils
;
...
...
@@ -470,18 +471,18 @@ public class Site {
* @param httpProxyList httpProxyList
* @return this
*/
public
Site
setHttpProxyPool
(
List
<
String
[]>
httpProxyList
)
{
this
.
httpProxyPool
=
new
ProxyPool
(
httpProxyList
)
;
public
Site
setHttpProxyPool
(
ProxyPool
proxyPool
)
{
this
.
httpProxyPool
=
proxyPool
;
return
this
;
}
public
Site
setHttpProxyPool
(
List
<
String
[]>
httpProxyList
,
boolean
isUseLastProxy
)
{
this
.
httpProxyPool
=
new
ProxyPool
(
httpProxyList
,
isUseLastProxy
);
this
.
httpProxyPool
=
new
Simple
ProxyPool
(
httpProxyList
,
isUseLastProxy
);
return
this
;
}
public
Site
enableHttpProxyPool
()
{
this
.
httpProxyPool
=
new
ProxyPool
();
this
.
httpProxyPool
=
new
Simple
ProxyPool
();
return
this
;
}
...
...
@@ -497,9 +498,4 @@ public class Site {
httpProxyPool
.
returnProxy
(
proxy
,
statusCode
);
}
public
Site
setProxyReuseInterval
(
int
reuseInterval
)
{
this
.
httpProxyPool
.
setReuseInterval
(
reuseInterval
);
return
this
;
}
}
webmagic-core/src/main/java/us/codecraft/webmagic/proxy/Proxy.java
View file @
25821c3c
...
...
@@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit;
*
* @author yxssfxwzy@sina.com <br>
* @since 0.5.1
* @see ProxyPool
* @see
Simple
ProxyPool
*/
public
class
Proxy
implements
Delayed
,
Serializable
{
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/proxy/ProxyPool.java
View file @
25821c3c
This diff is collapsed.
Click to expand it.
webmagic-core/src/main/java/us/codecraft/webmagic/proxy/SimpleProxyPool.java
0 → 100644
View file @
25821c3c
This diff is collapsed.
Click to expand it.
webmagic-core/src/test/java/us/codecraft/webmagic/proxy/ProxyTest.java
View file @
25821c3c
...
...
@@ -30,7 +30,7 @@ public class ProxyTest {
@Test
public
void
testProxy
()
{
ProxyPool
proxyPool
=
new
ProxyPool
(
httpProxyList
);
SimpleProxyPool
proxyPool
=
new
Simple
ProxyPool
(
httpProxyList
);
proxyPool
.
setReuseInterval
(
500
);
assertThat
(
proxyPool
.
getIdleNum
()).
isEqualTo
(
4
);
assertThat
(
new
File
(
proxyPool
.
getProxyFilePath
()).
exists
()).
isEqualTo
(
true
);
...
...
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