Advertisement
rg443

javascript proxy tester [proxynova, imgur, NodeJS]

Jan 20th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function proxynova(){
  2.     var options = {method: 'GET', host: 'www.proxynova.com', path: '/proxy_list.txt'};
  3.    
  4.     var req = http.request(options, function(response) {
  5.         var res_data = '';
  6.         response.on('data', function(chunk) {res_data += chunk;});
  7.         response.on('end', function() {
  8.             var m=res_data.match(/(\d+\.\d+\.\d+\.\d+:\d+)/gim);
  9.             if (m) console.log("proxy test: " +m.join(", "));
  10.             m && m.forEach(function(v,i,a){
  11.  
  12.                 /* proxy test */
  13.                 var p1=v.split(":");
  14.                 var options = {method: 'GET', 'path': 'http://imgur.com/stats', headers: {'Host': 'imgur.com' }};
  15.                 options.host=p1[0];
  16.                 options.port=p1[1];
  17.                 var req = http.request(options, function(response) {
  18.                     var bytes1=0;
  19.                     response.on('data', function(chunk) {bytes1+= chunk.length;});
  20.                     response.on('end', function() {
  21.                         console.log(response.statusCode,bytes1,req.proxy,response.statusCode==200&&bytes1==26777);
  22.                         if (response.statusCode==200&&bytes1>25000) {
  23.                             pl.push(req.proxy);
  24.                             }
  25.                         })
  26.                     });
  27.                 req.proxy=v;
  28.                 req.on('error', function(e) {console.log("# ERROR\t",req.proxy,e)});
  29.                 req.setTimeout(30000,function(){req.abort()});
  30.                 req.write('');
  31.                 req.end();
  32.                
  33.                 /* */
  34.                 })
  35.             });
  36.        
  37.         })
  38.     req.on('error', function(e) {});   
  39.     req.write('');
  40.     req.end();
  41.  
  42. }
  43.  
  44. var pl=[];
  45. proxynova();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement