CasperJS: Configure proxy options inside code
bots, casperjs, javascript, phantomjs
Solution
I needed CasperJS to run inside a node environment. So I have set up Spooky and the good news is that you can set one inside your code like this:
var spooky = new Spooky({
child: {
proxy: '192.128.101.42:9001',
/* ... */
},
/* ... */
},
Problem
I was wondering how we could set cli parameters inside our code and not by placing them at the end of our command like this: ``` casperjs casper_tor.js --proxy=127.0.0.1:9050 --proxy-type=socks5 ``` I've tested things like that but it didn't work: ``` var casper=require('casper').create(); casper.cli.options["proxy"] = "127.0.0.1:9050"; casper.cli.options["proxy-type"] = "socks5"; ... casper.run(); ``` What I'm trying to achieve is to set new proxies inside my code and to scrap my new ip address from whatsmyip.com to check that everything is right (I'm writing bots that will frequently change their proxies).