嗨,我想从网上获取一个代理列表并搜索它以找到有效的代理号码和端口。我的问题是当我抓取该网站时,我如何通过它进行搜索,它只识别 ips 和 poorts 并破坏其余部分?到目前为止我所做的一切都在工作,我如何只识别代理号码而不识别其他任何东西?很抱歉,任何帮助将不胜感激,但我是新手:)
package proxytester;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class ProxyTester{
public static void main(String[] args) {
try{
URL grab = new URL("http://www.example.com");
BufferedReader in = new BufferedReader(
new InputStreamReader(grab.openStream()));
String input;
while ((input = in.readLine()) != null) {
if(input.charAt(0)=='n'){// the site starts its proxy list with name but this line throws an error
System.out.println(input);
}else if(input.charAt(0)== ' '){
System.out.println("empty");
}else
continue;
}
in.close();
}catch(MalformedURLException aa){
System.out.println("site error");
}catch (IOException e) {
System.out.println("io error");
}
}//end main
}//end main