Non-interactive text proxy lists download for java

Non-interactive text proxy lists download for java


CODE for java
[ perl | python | java6 | wget | curl | java ]
  • with Java 5+, JDK 1.5+ and java.net.CookieHandler from java.net package:
    
    import java.net.CookieHandler;
    import java.net.URL;
    import java.net.URI;
    import java.net.URLConnection;
    import java.net.HttpURLConnection;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.FileOutputStream;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.List;
    import java.util.ArrayList;
    
    public class GetLists {
      
     static CookieHandler manager= new CookieHandler(){
     
      private Map<String,String> jar= new HashMap<String,String>();
    
      private Map<String,List<String>> getCookieMap(){
       if (jar==null) return null;
       List<String> clist=new ArrayList<String>();
       for (String k: jar.keySet()){
        clist.add(k+"="+jar.get(k));
       }
       Map<String,List<String>> ret=
         new HashMap<String,List<String>>();
       ret.put("Cookie",clist);
       return ret;
      }
       
      public Map<String,List<String>> get(
         URI uri, Map<String,List<String>> reqH){
       if (reqH==null) return getCookieMap();
       HashMap<String,List<String>> ret=
        new HashMap<String,List<String>>(reqH);
       ret.putAll(getCookieMap());
       return ret;
      }
       
      public void put(URI uri, Map<String,List<String>> respH)
         throws IOException{
       for (String k: respH.keySet()){
        if (k==null) continue;  
        if (k.equalsIgnoreCase("Set-Cookie")){
         for (String v: respH.get(k)){
          String kv[]=v.split(";")[0].trim().split("=",2);
          jar.put(kv[0],kv[1]);
         }
        }
       }
      }
     }; // anonymous subclass for CookieHandler
    
     public static void main(String args[]) throws Exception {
      String base="http://rosinstrument.com/cgi-bin/";
      String lists[]={
        "http1000", "httpanon500", "https500", "socks1000"};
      CookieHandler.setDefault(manager);
      URL loginUrl=new URL(base+"login.pl");
      loginUrl.openConnection().getContent();
    
      HttpURLConnection con=
        (HttpURLConnection)loginUrl.openConnection();
      con.setRequestMethod("POST");
      con.setDoOutput(true);
      con.setRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
    
      OutputStreamWriter wr=
        new OutputStreamWriter(con.getOutputStream());
      wr.write("login=[YOUR_LOGIN]&passwd=[YOUR_PASSWD]");
      wr.flush(); con.getContent();
    
      byte buf[]=new byte[1024];
      int read;
      for (String file: lists){
       InputStream is=new URL(base+"tl.pl?"+file). 
       openConnection().getInputStream();
       OutputStream os=new FileOutputStream(new File(file+".txt"));
       while ((read=is.read(buf,0,buf.length)) >=0){
        os.write(buf,0,read);
       }
      } // for
    
     } // main
    
    } // class GetLists
    
    
Results has been placed in text files http1000.txt, httpanon500.txt, https500.txt, socks1000.txt.