Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

site.setHttpProxyPool(httpProxyList, true)发生数组越界 #354

Closed
hero00ok opened this issue Jul 23, 2016 · 2 comments
Closed

site.setHttpProxyPool(httpProxyList, true)发生数组越界 #354

hero00ok opened this issue Jul 23, 2016 · 2 comments

Comments

@hero00ok
Copy link

hero00ok commented Jul 23, 2016

site.setHttpProxyPool(httpProxyList, true)发生数组越界,代码:

 @Override
    public Site getSite() {
        List httpProxyList  = new ArrayList();
        httpProxyList.add(new String[]{"127.0.0.1","8888"});
        site.setHttpProxyPool(httpProxyList, true);
        return site;
    }

错误内容:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
    at us.codecraft.webmagic.proxy.SimpleProxyPool.addProxy(SimpleProxyPool.java:159)
    at us.codecraft.webmagic.proxy.SimpleProxyPool.(SimpleProxyPool.java:63)
    at us.codecraft.webmagic.Site.setHttpProxyPool(Site.java:489)
    at us.codecraft.webmagic.processor.example.BaiduBaikePageProcessor.getSite(BaiduBaikePageProcessor.java:39)
    at us.codecraft.webmagic.Spider.(Spider.java:131)
    at us.codecraft.webmagic.Spider.create(Spider.java:121)
    at us.codecraft.webmagic.processor.example.BaiduBaikePageProcessor.main(BaiduBaikePageProcessor.java:45)
@cpaladin
Copy link

string[]里面需要4个元素,第一个和第二个是用户名和密码,代理认证使用的。第三和第四个才是ip和端口

@code4craft
Copy link
Owner

多谢提醒,文档已改,这个接口设计不太好,后面会重新写一下,新版见 #432

@sutra sutra added this to the WebMagic-0.7.4 milestone Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants