0

hi i want to grab a proxy list from the net and search through it to find working proxy numbers and port. my problem is when i grab the site how to i search through it it identify just the ips and poorts and disragrd the rest? all i got so far doeint work how do i identify just the proxy numbers and nothing else?? and sorry any help would be appreciated but i am a newb:)

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
Andy Hayden
  • 359,921
  • 101
  • 625
  • 535
user2155009
  • 103
  • 3

1 Answers1

0

I would suggest using regular expressions to find an ip address and the port. Here is a regular expression that is needed: java regex matching ip address and port number as captured groups This article explains how to use regular expressions in java: http://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/

Community
  • 1
  • 1
alu
  • 759
  • 7
  • 20
  • thanks allot i am using regex pattern "\\d{1,3}(?:\\.\\d{1,3}){3}(?::\\d{1,5})?"; which works fine if the proxy and port are seperated by : but if they are seperaated by a tab space then i tought "\\d{1,3}(?:\\.\\d{1,3}){3}(\\s\\s\\s\\s\\s\\s\\s\\d{1,5})?"; but i only outputs the proxy not the port any suggestions would be great as untill last night i didint even know of this java function thanks – user2155009 Mar 11 '13 at 14:50
  • There is the sequence "\\t" for a tab space. – alu Mar 11 '13 at 17:23