【问题标题】:Is it correct to dynamically change the proxy in this way in CasperJS?在 CasperJS 中以这种方式动态更改代理是否正确?
【发布时间】:2017-12-15 02:33:54
【问题描述】:

我尝试使用这种方法动态修改代理:

console.log('before set proxy: '+Date());
casper.then(function(){
    phantom.setProxy('127.0.0.1',"1080","manual",'','');
})
this.then(function(){
    console.log('after set proxy: '+Date());
})

但是,phantom.setProxy 每次花费 6 分钟:

before set proxy: Fri Dec 15 2017 09:56:41 GMT+0800 (CST)
[warning] [phantom] Loading resource failed with status=fail:         
https://chrome.google.com/webstore/category/extensions?utm_source=chrome-ntp-icon
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/7: done in 360210ms.
[info] [phantom] Step anonymous 3/7: done in 360230ms.
after set proxy: Fri Dec 15 2017 10:02:31 GMT+0800 (CST)

这种用法有什么问题? 而且其实phantom.setProxy('127.0.0.1',"1080","manual",'','')没有效果,但是phantom.setProxy('127.0.0.1',"1080","socks5",'','')是有效的。

【问题讨论】:

    标签: javascript casperjs


    【解决方案1】:

    这可能为时已晚,但我们开始吧..

    我在 PhantomJS 网站上没有看到任何参考资料,我是怎么在 SlimerJS 文档页面中看到的 >> https://docs.slimerjs.org/current/api/phantom.html#setproxy-host-port-proxytype-user-password

    代理类型: - “系统”:使用系统代理设置 - “auto”:自动检测代理设置 - “config-url”:自动代理配置 URL - “袜子” - “袜子5” - “http” - / null / 未定义

    答案是,“手动”不是可能的选项之一,您可以使用“http”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2023-04-10
      • 2014-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多