-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetProxies.js
executable file
·87 lines (74 loc) · 2.44 KB
/
getProxies.js
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
//Get proxies from different source
const { spawn } = require('child_process');
const request = require("request");
var fs = require('fs');
const Chromeless = require('chromeless').Chromeless;
const Chromelauncher = require('chrome-launcher');
//Get proxies from chill's project
function getChillProxies() {
const child = spawn('proxy-lists', ['getProxies', '--protocols="http"']);
console.log('ChillProxies Updated!');
}
//Get proxies from fate0's project
function getFate0Proxy() {
var url = 'https://raw.githubusercontent.com/fate0/proxylist/master/proxy.list'
request({
url: url,
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
var proxylist = body.split('\n');
fs.writeFileSync('fate0Proxies.txt', '', 'utf8');
for(var n = 0; n < proxylist.length - 1; n++) {
var proxytype = JSON.parse(proxylist[n]).type;
if(proxytype === 'http') {
fs.appendFile('fate0Proxies.txt', JSON.parse(proxylist[n]).host + ':' + JSON.parse(proxylist[n]).port + '\n', function (err) {
if (err) throw err;
});
}
}
console.log('Fate0Proxy Updated!');
}
else {
console.log('Response Code is ' + response.statusCode);
}
});
}
async function getProxies24() {
const chrome = await Chromelauncher.launch({
port: 9222,
chromeFlags: [
'--window-size=1200,800',
'--disable-gpu',
'--headless'
]
});
const chromeless = new Chromeless({
launchChrome: false
})
var proxyContent = await chromeless
.goto('http://www.proxyserverlist24.top/')
.wait(10000)
.click('div.date-posts > div.post-outer:first-child > div > h3 > a')
.wait(10000)
.evaluate(function() {
var content = document.querySelector('pre.alt2').innerHTML;
return content;
})
await chromeless.end();
var proxylist = proxyContent.split('\n');
fs.writeFileSync('Proxies24.txt', '', 'utf8');
for(var n = 1; n < proxylist.length - 1; n++) {
fs.appendFile('Proxies24.txt', proxylist[n] + '\n', function (err) {
if (err) throw err;
});
}
console.log('Proxies24 Updated!');
}
//////////////////////////////////////////////////////////////////////////////////////
getChillProxies();
getFate0Proxy();
getProxies24();
setTimeout(function() {
process.exit();
}, 60000);