I'm trying to set a proxy for Nightmare.js but the proxy setting isn't taking. It just visits the site directly.
const Nightmare = require('nightmare');
const nightmare = new Nightmare({
show: true,
switches: {
'proxy-server': 'server.proxyservice.com:8080',
'ignore-certificate-errors': true
}
});
async function test(url){
try{
const nightmare = Nightmare({show:true});
await nightmare.authentication('proxyUsername', 'proxyPassword');
await nightmare.cookies.clearAll();
await nightmare.useragent("Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36")
const response = await nightmare.goto(url);
await nightmare.wait('#gbqfbb',10000);
}catch(err){
throw new Error(err)
}
}
test('https://www.google.com').then(console.log).catch(console.log);
nightmare.end(() => "some value");
via xendi
No comments:
Post a Comment