在网站上找到ip?

时间:2013-03-11 00:00:14

标签: proxy

嗨我想从网上获取代理列表并搜索它以查找工作代理号码和端口。我的问题是,当我抓住网站如何通过它搜索它只识别ips和poorts并disragrd其余的?到目前为止,我所做的一切都是工作 我如何识别代理号码,没有别的?对不起,任何帮助将不胜感激,但我是一个新人:)

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

1 个答案:

答案 0 :(得分:0)

我建议使用正则表达式来查找IP地址和端口。这是一个需要的正则表达式:java regex matching ip address and port number as captured groups 本文介绍如何在java中使用正则表达式:http://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/