Advertisement
rg443

javascript proxy checker [imgur, NodeJS]

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