CasperJS:在代码中配置代理选项 [英] CasperJS: Configure proxy options inside code

查看:98
本文介绍了CasperJS:在代码中配置代理选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在我们的代码中设置cli参数,而不是将它们放在我们命令的末尾,如下所示:

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();

我想要实现的是在我的代码中设置新的代理并废弃我的新ip来自whatsmyip.com的地址,检查一切是否正确(我正在编写经常更改其代理的机器人)。

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).

推荐答案

我需要CasperJS在节点环境中运行。所以我设置了Spooky ,好消息是你可以在你的代码中设置一个像这样:

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',
            /* ... */
        },
        /* ... */
    },

这篇关于CasperJS:在代码中配置代理选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆