PhantomJS


Using Crawlera in Phantom object:


var page = require('webpage').create();

phantom.setProxy('proxy.crawlera.com', '8010', 'http') // change to https when making HTTPS requests
page.customHeaders={'Proxy-Authorization': 'Basic '+btoa('APIKEY:')}; // Make sure to include ':' at the end

page.open('http://httpbin.org/ip', function (status) {
    page.evaluate(function(){});
    console.log(page.content);
    
    phantom.exit();
});

to run use:

phantomjs myscript.js

add '--ignore-ssl-errors=true' when making HTTPS request.


Using Crawlera in Page object:


var page = require('webpage').create();

page.setProxy('http://proxy.crawlera.com:8010/'); // change scheme to https:// when making HTTPS requests
page.customHeaders={'Proxy-Authorization': 'Basic '+btoa('APIKEY:')}; // Make sure to include ':' at the end

page.open('http://httpbin.org/ip', function (status) {
    page.evaluate(function(){});
    console.log(page.content);
    
    phantom.exit();
});

to run use:

phantomjs myscript.js

add '--ignore-ssl-errors=true' when making HTTPS request.


Using Crawlera in Phantom object with arguments:


var page = require('webpage').create(),
    system = require('system'),
    host, port, scheme, apikey, address;

host = system.args[1];
port = system.args[2];
scheme = system.args[3];
apikey = system.args[4];
address = system.args[5];

phantom.setProxy(host, port, scheme);
page.customHeaders={'Proxy-Authorization': 'Basic '+btoa(apikey)};

page.open(address, function (status) {
    page.evaluate(function(){});
    console.log(page.content);
    
    phantom.exit();
});

to run use:

phantomjs myscript.js 'proxy.crawlera.com' '8010' '<http or https>' '<APIKEY>:' 'http://httpbin.org/ip' // Make sure to include ':' at the end

add '--ignore-ssl-errors=true' when making HTTPS request.


Using Crawlera in Page object with arguments:


var page = require('webpage').create(),
    system = require('system'),
    proxy, apikey, address;

proxy = system.args[1];
apikey = system.args[2];
address = system.args[3];

page.setProxy(proxy);
page.customHeaders={'Proxy-Authorization': 'Basic '+btoa(apikey)};

page.open(address, function (status) {
    page.evaluate(function(){});
    console.log(page.content);
    
    phantom.exit();
});

to run use:

phantomjs myscript.js '<http or https>://proxy.crawlera.com' '<APIKEY>:' 'http://httpbin.org/ip' // Make sure to include ':' at the end

add '--ignore-ssl-errors=true' when making HTTPS request.


CasperJS


Using Crawlera in Phantom object:


var casper = require('casper').create();

casper.start();
phantom.setProxy('proxy.crawlera.com','8010', 'http'); // change to https when making HTTPS requests

casper.open('https://httpbin.org/ip', {
  headers: {
    'Proxy-Authorization': 'Basic '+btoa('APIKEY:') // Make sure to include ':' at the end
  }}).then(function(response) {
    this.echo(this.getHTML());
});

casper.run();

to run use:

casperjs myscript.js

add '--ignore-ssl-errors=true' when making HTTPS request.