-
Notifications
You must be signed in to change notification settings - Fork 3
/
rotating_proxies.js
46 lines (38 loc) · 1.23 KB
/
rotating_proxies.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
const csv = require('async-csv');
const fs = require('fs').promises;
const axios = require("axios");
(async () => {
// Read file from disk:
const csvFile = await fs.readFile('proxy_list.csv');
// Convert CSV string into rows:
const data = await csv.parse(csvFile);
await Promise.all(data.map(async (item) => {
try {
// Create the Proxy object
proxy_no_auth = {
host: '206.253.164.122',
port: 80
}
// Proxy with authentication
proxy_with_auth = {
host: '46.138.246.248',
port: 8088,
auth: {
username: 'USERNAME',
password: 'PASSWORD'
}
}
// This URL returns the IP
const url = `https://httpbin.org/ip`;
// Call the GET method on the URL with proxy information
const response = await axios.get(url, {
proxy: proxy_no_auth
});
// Print effective IP address
console.log(response.data);
} catch (err) {
// Log failed proxy
console.log('Proxy Failed: ' + item[0]);
}
}));
})();