1. samair.ru/proxyを解析し、プロキシリストをmysqlにマージします。
2.データベースを通過し、受信したプロキシのタイムアウトを確認します。
データベース
      PhpMyAdminからの基本構造の画面
だから、まずパーサー。
  import java.io.BufferedReader; 
      
        
        
        
      
     import java.io.IOException; 
      
        
        
        
      
     import java.io.InputStreamReader; 
      
        
        
        
      
     import java.net.HttpURLConnection; 
      
        
        
        
      
     import java.net.MalformedURLException; 
      
        
        
        
      
     import java.net.ProtocolException; 
      
        
        
        
      
     import java.net.URL; 
      
        
        
        
      
     import java.sql.Connection; 
      
        
        
        
      
     import java.sql.DriverManager; 
      
        
        
        
      
     import java.sql.ResultSet; 
      
        
        
        
      
     import java.sql.SQLException; 
      
        
        
        
      
     import java.sql.Statement; 
      
        
        
        
      
     
      
        
        
        
      
     
      
        
        
        
      
     public class ProxyHunter { 
      
        
        
        
      
     
      
        
        
        
      
        /** 
      
        
        
        
      
         * @param args 
      
        
        
        
      
         * @throws ClassNotFoundException 
      
        
        
        
      
         * @throws SQLException 
      
        
        
        
      
         * @throws IOException 
      
        
        
        
      
         */ 
      
        
        
        
      
        public static void main ( String [] args ) throws ClassNotFoundException, SQLException, IOException { 
      
        
        
        
      
          // TODO Auto-generated method stub 
      
        
        
        
      
          Class.forName ( "com.mysql.jdbc.Driver" ) ; 
      
        
        
        
      
          //  MySQL 
      
        
        
        
      
          Connection conn = DriverManager.getConnection ( "jdbc:mysql://192.168.1.7:3306/database" , "username" , "password" ) ; 
      
        
        
        
      
          //192.168.1.7 -  ,    localhost 
      
        
        
        
      
          //database -      
      
        
        
        
      
          //username, password -      MySQL 
      
        
        
        
      
          Statement st = conn.createStatement () ; 
      
        
        
        
      
          URL connection = null ; 
      
        
        
        
      
          String [] replacements = new String [ 10 ] ; 
      
        
        
        
      
          String host = null ; 
      
        
        
        
      
          String port = null ; 
      
        
        
        
      
          String anon_level = null ; 
      
        
        
        
      
          String country = null ; 
      
        
        
        
      
          int cursor = 0 ; 
      
        
        
        
      
          HttpURLConnection urlconn = null ; 
      
        
        
        
      
          int n = 1 ; 
      
        
        
        
      
          while ( n <= 50 ) 
      
        
        
        
      
          { 
      
        
        
        
      
            if ( n < 10 ) 
      
        
        
        
      
            { 
      
        
        
        
      
              connection = new URL ( "www.samair.ru/proxy/ip-address-0"; +n+ ".htm" ) ; 
      
        
        
        
      
            } 
      
        
        
        
      
            else 
      
        
        
        
      
            { 
      
        
        
        
      
              connection = new URL ( "www.samair.ru/proxy/ip-address-"; +n+ ".htm" ) ; 
      
        
        
        
      
            } 
      
        
        
        
      
            
      
        
        
        
      
            System.out.println ( "Starting page: " +Integer.toString ( n )) ; 
      
        
        
        
      
            urlconn = ( HttpURLConnection ) connection.openConnection () ; 
      
        
        
        
      
            urlconn.setRequestMethod ( "GET" ) ; 
      
        
        
        
      
            urlconn.connect () ; 
      
        
        
        
      
            // GET     samair' 
      
        
        
        
      
            java.io.InputStream in = urlconn.getInputStream () ; 
      
        
        
        
      
            BufferedReader reader = new BufferedReader ( new InputStreamReader ( in )) ; 
      
        
        
        
      
            String text = null ; 
      
        
        
        
      
            String line = null ; 
      
        
        
        
      
            while (( line = reader.readLine ()) != null ) 
      
        
        
        
      
            { 
      
        
        
        
      
              text += line; 
      
        
        
        
      
            } 
      
        
        
        
      
            //   
      
        
        
        
      
            replacements = text.substring ( text.indexOf ( "<script src=\"http://samair.ru:81/js/m.js" type="text/javascript"> ) + "<script src=\"http://samair.ru:81/js/m.js" type="text/javascript"> .length () , text.indexOf ( "</script></head>" )) .split ( ";" ) ; 
      
        
        
        
      
            // , ,          javascript' 
      
        
        
        
      
            //     10    ,         
      
        
        
        
      
            //replacements -      
      
        
        
        
      
            cursor = text.indexOf ( "<tr><td>" ) ; 
      
        
        
        
      
            while ( cursor != - 1 ) 
      
        
        
        
      
              { 
      
        
        
        
      
              cursor += "<tr><td>" .length () ; 
      
        
        
        
      
              host = text.substring ( cursor, text.indexOf ( "<script type=\"text/javascript\">" , cursor )) ; 
      
        
        
        
      
              //host -    
      
        
        
        
      
              port = text.substring ( text.indexOf ( ">document.write(\":\"+" , cursor ) + ">document.write(\":\"+" .length () , text.indexOf ( ")</script>" , cursor )) ; 
      
        
        
        
      
              port = removeChar ( port, '+' ) ; 
      
        
        
        
      
              for ( int i = 0 ; i< 10 ; i++ ) 
      
        
        
        
      
              { 
      
        
        
        
      
                port = port.replaceAll ( replacements [ i ] .split ( "=" )[ 0 ] , replacements [ i ] .split ( "=" )[ 1 ]) ; 
      
        
        
        
      
                //    
      
        
        
        
      
              } 
      
        
        
        
      
              //port -   
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              anon_level = text.substring ( cursor, text.indexOf ( "</td><td>" , cursor )) ; 
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              country = text.substring ( cursor, text.indexOf ( "</td></tr>" , cursor )) ; 
      
        
        
        
      
              //   -    ,     )       
      
        
        
        
      
              ResultSet rs = st.executeQuery ( "select host, port from proxies where host = '" +host+ "' and port = '" +port+ "'" ) ; 
      
        
        
        
      
              if ( !rs.next ()) 
      
        
        
        
      
              { 
      
        
        
        
      
                st.executeUpdate ( "INSERT INTO proxies (host, port, anon_level, country) VALUES ('" +host+ "', '" +port+ "', '" +anon_level+ "', '" +country+ "')" ) ; 
      
        
        
        
      
                System.out.println ( "Added: " +host+ ":" +port ) ; 
      
        
        
        
      
                //        ,     
      
        
        
        
      
              } 
      
        
        
        
      
              cursor = text.indexOf ( "<tr><td>" , cursor ) ; 
      
        
        
        
      
              } 
      
        
        
        
      
            
      
        
        
        
      
            n++; 
      
        
        
        
      
     
      
        
        
        
      
          } 
      
        
        
        
      
          
      
        
        
        
      
          st.close () ; 
      
        
        
        
      
          conn.close () ; 
      
        
        
        
      
        } 
      
        
        
        
      
        
      
        
        
        
      
        public static String removeChar ( String s, char c ) { 
      
        
        
        
      
             String r = "" ; 
      
        
        
        
      
             for ( int i = 0 ; i < s.length () ; i ++ ) { 
      
        
        
        
      
                if ( s.charAt ( i ) != c ) r += s.charAt ( i ) ; 
      
        
        
        
      
                } 
      
        
        
        
      
             return r; 
      
        
        
        
      
          } 
      
        
        
        
      
     
      
        
        
        
      
     }
      
      そして直接チェッカー自身
  import java.io.BufferedReader; 
      
        
        
        
      
     import java.io.IOException; 
      
        
        
        
      
     import java.io.InputStreamReader; 
      
        
        
        
      
     import java.net.HttpURLConnection; 
      
        
        
        
      
     import java.net.MalformedURLException; 
      
        
        
        
      
     import java.net.ProtocolException; 
      
        
        
        
      
     import java.net.URL; 
      
        
        
        
      
     import java.sql.Connection; 
      
        
        
        
      
     import java.sql.DriverManager; 
      
        
        
        
      
     import java.sql.ResultSet; 
      
        
        
        
      
     import java.sql.SQLException; 
      
        
        
        
      
     import java.sql.Statement; 
      
        
        
        
      
     
      
        
        
        
      
     
      
        
        
        
      
     public class ProxyHunter { 
      
        
        
        
      
     
      
        
        
        
      
        /** 
      
        
        
        
      
         * @param args 
      
        
        
        
      
         * @throws ClassNotFoundException 
      
        
        
        
      
         * @throws SQLException 
      
        
        
        
      
         * @throws IOException 
      
        
        
        
      
         */ 
      
        
        
        
      
        public static void main ( String [] args ) throws ClassNotFoundException, SQLException, IOException { 
      
        
        
        
      
          // TODO Auto-generated method stub 
      
        
        
        
      
          Class.forName ( "com.mysql.jdbc.Driver" ) ; 
      
        
        
        
      
          //  MySQL 
      
        
        
        
      
          Connection conn = DriverManager.getConnection ( "jdbc:mysql://192.168.1.7:3306/database" , "username" , "password" ) ; 
      
        
        
        
      
          //192.168.1.7 -  ,    localhost 
      
        
        
        
      
          //database -      
      
        
        
        
      
          //username, password -      MySQL 
      
        
        
        
      
          Statement st = conn.createStatement () ; 
      
        
        
        
      
          URL connection = null ; 
      
        
        
        
      
          String [] replacements = new String [ 10 ] ; 
      
        
        
        
      
          String host = null ; 
      
        
        
        
      
          String port = null ; 
      
        
        
        
      
          String anon_level = null ; 
      
        
        
        
      
          String country = null ; 
      
        
        
        
      
          int cursor = 0 ; 
      
        
        
        
      
          HttpURLConnection urlconn = null ; 
      
        
        
        
      
          int n = 1 ; 
      
        
        
        
      
          while ( n <= 100 ) 
      
        
        
        
      
          { 
      
        
        
        
      
            if ( n < 10 ) 
      
        
        
        
      
            { 
      
        
        
        
      
              connection = new URL ( "www.samair.ru/proxy/ip-address-0"; +n+ ".htm" ) ; 
      
        
        
        
      
            } 
      
        
        
        
      
            else 
      
        
        
        
      
            { 
      
        
        
        
      
              connection = new URL ( "www.samair.ru/proxy/ip-address-"; +n+ ".htm" ) ; 
      
        
        
        
      
            } 
      
        
        
        
      
            
      
        
        
        
      
            System.out.println ( "Starting page: " +Integer.toString ( n )) ; 
      
        
        
        
      
            urlconn = ( HttpURLConnection ) connection.openConnection () ; 
      
        
        
        
      
            urlconn.setRequestMethod ( "GET" ) ; 
      
        
        
        
      
            urlconn.connect () ; 
      
        
        
        
      
            // GET     samair' 
      
        
        
        
      
            java.io.InputStream in = urlconn.getInputStream () ; 
      
        
        
        
      
            BufferedReader reader = new BufferedReader ( new InputStreamReader ( in )) ; 
      
        
        
        
      
            String text = null ; 
      
        
        
        
      
            String line = null ; 
      
        
        
        
      
            while (( line = reader.readLine ()) != null ) 
      
        
        
        
      
            { 
      
        
        
        
      
              text += line; 
      
        
        
        
      
            } 
      
        
        
        
      
            //   
      
        
        
        
      
            replacements = text.substring ( text.indexOf ( "<script src=\"http://samair.ru:81/js/m.js" type="text/javascript"> ) + "<script src=\"http://samair.ru:81/js/m.js" type="text/javascript"> .length () , text.indexOf ( "</script></head>" )) .split ( ";" ) ; 
      
        
        
        
      
            // , ,          javascript' 
      
        
        
        
      
            //     10    ,         
      
        
        
        
      
            //replacements -      
      
        
        
        
      
            cursor = text.indexOf ( "<tr><td>" ) ; 
      
        
        
        
      
            while ( cursor != - 1 ) 
      
        
        
        
      
              { 
      
        
        
        
      
              cursor += "<tr><td>" .length () ; 
      
        
        
        
      
              //host -    
      
        
        
        
      
              //-          javascript' 
      
        
        
        
      
              // plaintext' 
      
        
        
        
      
              // 
      
        
        
        
      
              if ( text.indexOf ( ">document.write(\":\"+" , cursor ) != - 1 ) 
      
        
        
        
      
              { 
      
        
        
        
      
                //  javascript 
      
        
        
        
      
                host = text.substring ( cursor, text.indexOf ( "<script type=\"text/javascript\">" , cursor )) ; 
      
        
        
        
      
                port = text.substring ( text.indexOf ( ">document.write(\":\"+" , cursor ) + ">document.write(\":\"+" .length () , text.indexOf ( ")</script>" , cursor )) ; 
      
        
        
        
      
                port = removeChar ( port, '+' ) ; 
      
        
        
        
      
                for ( int i = 0 ; i< 10 ; i++ ) 
      
        
        
        
      
                { 
      
        
        
        
      
                  port = port.replaceAll ( replacements [ i ] .split ( "=" )[ 0 ] , replacements [ i ] .split ( "=" )[ 1 ]) ; 
      
        
        
        
      
                  //    
      
        
        
        
      
                } 
      
        
        
        
      
              } 
      
        
        
        
      
              else 
      
        
        
        
      
              { 
      
        
        
        
      
                // plaintext 
      
        
        
        
      
                host = text.substring ( cursor, text.indexOf ( ":" , cursor )) ; 
      
        
        
        
      
                port = text.substring ( text.indexOf ( ":" , cursor ) + 1 , text.indexOf ( "</td><td>" , cursor )) ; 
      
        
        
        
      
              } 
      
        
        
        
      
              //port -   
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              anon_level = text.substring ( cursor, text.indexOf ( "</td><td>" , cursor )) ; 
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              cursor = text.indexOf ( "</td><td>" , cursor ) + "</td><td>" .length () ; 
      
        
        
        
      
              country = text.substring ( cursor, text.indexOf ( "</td></tr>" , cursor )) ; 
      
        
        
        
      
              //   -    ,     )       
      
        
        
        
      
              ResultSet rs = st.executeQuery ( "select host, port from proxies where host = '" +host+ "' and port = '" +port+ "'" ) ; 
      
        
        
        
      
              if ( !rs.next ()) 
      
        
        
        
      
              { 
      
        
        
        
      
                st.executeUpdate ( "INSERT INTO proxies (host, port, anon_level, country) VALUES ('" +host+ "', '" +port+ "', '" +anon_level+ "', '" +country+ "')" ) ; 
      
        
        
        
      
                System.out.println ( "Added: " +host+ ":" +port ) ; 
      
        
        
        
      
                //        ,     
      
        
        
        
      
              } 
      
        
        
        
      
              cursor = text.indexOf ( "<tr><td>" , cursor ) ; 
      
        
        
        
      
              } 
      
        
        
        
      
            
      
        
        
        
      
            n++; 
      
        
        
        
      
     
      
        
        
        
      
          } 
      
        
        
        
      
          
      
        
        
        
      
          st.close () ; 
      
        
        
        
      
          conn.close () ; 
      
        
        
        
      
        } 
      
        
        
        
      
        
      
        
        
        
      
        public static String removeChar ( String s, char c ) { 
      
        
        
        
      
             String r = "" ; 
      
        
        
        
      
             for ( int i = 0 ; i < s.length () ; i ++ ) { 
      
        
        
        
      
                if ( s.charAt ( i ) != c ) r += s.charAt ( i ) ; 
      
        
        
        
      
                } 
      
        
        
        
      
             return r; 
      
        
        
        
      
          } 
      
        
        
        
      
     
      
        
        
        
      
     }
      
      一般に、スレッドを使用した配列の正しい実装に関する疑問に悩まされています。 Javaにはそのような目的のために特別なものがあるように見えますが、最初に思い浮かんだのは、スレッドの配列です。
そして、自転車の発明をscらないでください。 ここでの目標は、楽しみに加えてMySQLで作業することだけでした。 このようなものをコンソールに出力するために、すべてのPrintStackTrace()をコメント化できます。
結果
      実証済みのベースの一部。 遅延が-1の場合、プロキシが無効になります。
PS
MySQLドライバーはここからダウンロードできます: www.mysql.com/products/connector
MySQL用のJDBCドライバー(Connector / J)を選択します。 アーカイブを展開し、そこからmysql-connector-java-5.1.10-bin.jarファイルを取り出して、プロジェクトフォルダーにドロップします。 次に、Eclipseでプロジェクトを右クリックし、[プロパティ]-> [Javaビルドパス]-> [ライブラリ]-> [JARを追加]を選択します。
      解決策は次のとおりです。
PPS
EclipseからHTMLへのコードのエクスポートは、 Java2Htmlコンバーターを使用して実装されます
© @nixan