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;
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 SimpleProxyPool(httpProxyList, isUseLastProxy);
return this;
}
public Site enableHttpProxyPool() {
this.httpProxyPool=new ProxyPool();
this.httpProxyPool=new SimpleProxyPool();
return this;
}
......@@ -497,9 +498,4 @@ public class Site {
httpProxyPool.returnProxy(proxy,statusCode);
}
public Site setProxyReuseInterval(int reuseInterval) {
this.httpProxyPool.setReuseInterval(reuseInterval);
return this;
}
}
......@@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit;
*
* @author yxssfxwzy@sina.com <br>
* @since 0.5.1
* @see ProxyPool
* @see SimpleProxyPool
*/
public class Proxy implements Delayed, Serializable {
......
......@@ -30,7 +30,7 @@ public class ProxyTest {
@Test
public void testProxy() {
ProxyPool proxyPool = new ProxyPool(httpProxyList);
SimpleProxyPool proxyPool = new SimpleProxyPool(httpProxyList);
proxyPool.setReuseInterval(500);
assertThat(proxyPool.getIdleNum()).isEqualTo(4);
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