-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (42 loc) · 1.35 KB
/
Copy pathindex.js
File metadata and controls
53 lines (42 loc) · 1.35 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
//Dependencies
const Request = require("request")
const Fs = require("fs")
//Main
async function init(){
const Proxies = Fs.readFileSync(`${__dirname}/proxies.txt`, "utf8")
return new Promise(resolve =>{
Request("https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all", function(err, res, body){
if(err){
resolve()
return
}
var results = ""
body = body.split("\n")
for( i in body ){
if(Proxies.indexOf(body[i]) == -1){
if(results.length == 0){
results = body[i]
}else{
results += `\n${body[i]}`
}
}
}
if(Proxies.length == 0){
Fs.writeFileSync(`${__dirname}/proxies.txt`, results, "utf8")
}else{
Fs.writeFileSync(`${__dirname}/proxies.txt`, `${Proxies}\n${results}`, "utf8")
}
resolve()
})
})
}
function get(){
var Proxies = Fs.readFileSync(`${__dirname}/proxies.txt`, "utf8").split("\n")
Proxies = JSON.parse(JSON.stringify(Proxies).replace(/\\r/g, ""))
return Proxies
}
//Exporter
module.exports = {
init: init,
get: get
}