-
Notifications
You must be signed in to change notification settings - Fork 1
/
nightProxy.js
33 lines (29 loc) · 1005 Bytes
/
nightProxy.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
// Test Proxy is working ------------------------------------------------------
var Nightmare = require('nightmare');
var proxyNightmare = Nightmare({
switches: {
'proxy-server': 'fr.proxymesh.com:31280' // set the proxy server here ...
},
show: true
});
proxyNightmare
.authentication('jammie', 'jameso01') // ... and authenticate here before `goto`
.goto('http://www.ipchicken.com')
.evaluate(function() {
return document.querySelector('b').innerText.replace(/[^\d\.]/g, '');
})
.end()
.then(function(ip) { // This will log the Proxy's IP
console.log('proxy IP:', ip);
});
// Regular nightmare for reference ---------------------------------------------
var regularNightmare = Nightmare({ show: true });
regularNightmare
.goto('http://www.ipchicken.com')
.evaluate(function() {
return document.querySelector('b').innerText.replace(/[^\d\.]/g, '');
})
.end()
.then(function(ip) { // This will log the your local IP
console.log('local IP:', ip);
});