HtmlPage page = null;
List <HtmlElement> ips = null ;
List <HtmlElement> ports = null ;
ArrayList <String> proxies = new ArrayList();
String temp;
String baseUrl = "https://free-proxy-list.net/" ;
WebClient client = new WebClient();
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(false);
try{
page = client.getPage(baseUrl);
ips = page.getByXPath("//table/tbody/tr/td[position()=1]/text()");
ports = page.getByXPath("//table/tbody/tr/td[position()=2]/text()");
for(int i=0;i<ips.size();i++){
System.out.println("IP: "+ips.get(i));
temp=(ips.get(i)+":"+ports.get(i));
System.out.println("Temp: "+temp);
if(!(temp.matches(".*[a-z].*"))){
proxies.add(temp);
}
}
for (int i=0;i<ips.size();i++){
System.out.println(proxies.get(i));
}
}
catch(Exception e){
e.printStackTrace();
}
你好,我在这篇文章中不断收到java.lang.IndexOutOfBoundsException: Index: 308, Size: 308
这样的错误:temp=(ips.get(i)+":"+ports.get(i));
无法理解为什么