Commit 25821c3c authored by yihua.huang's avatar yihua.huang

Merge branch 'EdwardsBean-proxy-strategy'

parents b5413368 61c28a01
...@@ -5,6 +5,7 @@ import com.google.common.collect.Table; ...@@ -5,6 +5,7 @@ import com.google.common.collect.Table;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import us.codecraft.webmagic.proxy.Proxy; import us.codecraft.webmagic.proxy.Proxy;
import us.codecraft.webmagic.proxy.SimpleProxyPool;
import us.codecraft.webmagic.proxy.ProxyPool; import us.codecraft.webmagic.proxy.ProxyPool;
import us.codecraft.webmagic.utils.UrlUtils; import us.codecraft.webmagic.utils.UrlUtils;
...@@ -470,18 +471,18 @@ public class Site { ...@@ -470,18 +471,18 @@ public class Site {
* @param httpProxyList httpProxyList * @param httpProxyList httpProxyList
* @return this * @return this
*/ */
public Site setHttpProxyPool(List<String[]> httpProxyList) { public Site setHttpProxyPool(ProxyPool proxyPool) {
this.httpProxyPool=new ProxyPool(httpProxyList); this.httpProxyPool = proxyPool;
return this; return this;
} }
public Site setHttpProxyPool(List<String[]> httpProxyList, boolean isUseLastProxy) { public Site setHttpProxyPool(List<String[]> httpProxyList, boolean isUseLastProxy) {
this.httpProxyPool=new ProxyPool(httpProxyList, isUseLastProxy); this.httpProxyPool=new SimpleProxyPool(httpProxyList, isUseLastProxy);
return this; return this;
} }
public Site enableHttpProxyPool() { public Site enableHttpProxyPool() {
this.httpProxyPool=new ProxyPool(); this.httpProxyPool=new SimpleProxyPool();
return this; return this;
} }
...@@ -497,9 +498,4 @@ public class Site { ...@@ -497,9 +498,4 @@ public class Site {
httpProxyPool.returnProxy(proxy,statusCode); httpProxyPool.returnProxy(proxy,statusCode);
} }
public Site setProxyReuseInterval(int reuseInterval) {
this.httpProxyPool.setReuseInterval(reuseInterval);
return this;
}
} }
...@@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit; ...@@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit;
* *
* @author yxssfxwzy@sina.com <br> * @author yxssfxwzy@sina.com <br>
* @since 0.5.1 * @since 0.5.1
* @see ProxyPool * @see SimpleProxyPool
*/ */
public class Proxy implements Delayed, Serializable { public class Proxy implements Delayed, Serializable {
......
...@@ -30,7 +30,7 @@ public class ProxyTest { ...@@ -30,7 +30,7 @@ public class ProxyTest {
@Test @Test
public void testProxy() { public void testProxy() {
ProxyPool proxyPool = new ProxyPool(httpProxyList); SimpleProxyPool proxyPool = new SimpleProxyPool(httpProxyList);
proxyPool.setReuseInterval(500); proxyPool.setReuseInterval(500);
assertThat(proxyPool.getIdleNum()).isEqualTo(4); assertThat(proxyPool.getIdleNum()).isEqualTo(4);
assertThat(new File(proxyPool.getProxyFilePath()).exists()).isEqualTo(true); assertThat(new File(proxyPool.getProxyFilePath()).exists()).isEqualTo(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment