0

Here are some options i already try but none of them work for me
is there any way to change proxy before we hit any particular website ?

var casper = require("casper").create({
setProxy: "proxy here",
// --proxy: "proxy here",
webSecurityEnabled: false,
verbose: true,
logLevel: "debug",
waitTimeout: 100000,
pageSettings: {
    userAgent: "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0",
    proxy: 'proxy here'
}});
var url = 'http://whatismyipaddress.com/';
var fs = require('fs');
var path = 'ip_check.txt';
casper.start(url, function() {
    casper.cli.options["proxy"] = "proxy here";
    var js = this.evaluate(function() {
        return document; 
    }); 
    fs.write(path,js.all[0].outerHTML,'w'); 
});
casper.run();

1 Answers1

1

You can send a proxy argument like this

casperjs --proxy="switchproxy.proxify.net:7498" xyz.js

gkubed
  • 1,849
  • 3
  • 32
  • 45