-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.js
More file actions
90 lines (69 loc) · 2.2 KB
/
Copy pathrequest.js
File metadata and controls
90 lines (69 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var request=require("request");
function reqAction(opts){
var pro=new Promise(function(resolve,reject){
request(opts,(err,res,body)=>{
if(body){
resolve(body);
}
})
});
return pro;
}
var headers={
'User-Agent': `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36`
}
var page=0;
let timer=setInterval(()=>{
page++;
console.log(page);
var thisOpts={
url:"http://ip.ningli.win/?page="+page,
headers:headers
}
reqAction(thisOpts).then(data=>{
console.log(data);
}).catch(err=>{
console.log({"err":err});
})
if(page>=125){
clearInterval(timer);
}
},1000)
// try {
// var targetOptions = {
// method: 'GET',
// url: 'http://ningli.win',
// timeout: 22000
// };
// // console.log(proxyList);
// var proxyList=arr;
// var len=proxyList.length;
// var i=0;
// proxyList.forEach(function (obj) {
// var proxyurl=obj.ip;
// console.log(`testing ${proxyurl}`);
// targetOptions.proxy = 'http://' + proxyurl;
// request(targetOptions, function (error, response, body) {
// i++;
// console.log('body',body);
// try {
// if (error) throw error;
// arr.push(proxyurl)
// body = body.toString();
// var sqlStr='select * from iptable where ip="'+proxyurl+'"';
// sql.select(sqlStr,"ips").then(res=>{
// if(res["data"].length==0){
// var sqlStr1='insert into iptable(ip) values("'+proxyurl+'")'
// sql.select(sqlStr1,'ips').then(result=>{
// console.log("写入成功",proxyurl);
// })
// }
// });
// } catch (e) {
// console.error('error-------'+e);
// }
// });
// });
// } catch (error) {
// console.log(error);
// }