我尝试通过使用此方法动态修改代理:
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",'','')
是有效的。
这可能为时已晚,但我们走了..
我在phantomjs网站上没有看到任何参考,我在Slimerjs doc page>> https://docs.slimerjs.org/current/current/api/phantom.html#setom.html#setproxy-host-host-port-port-port-proxypepe - 用户password
代理类型: - "系统":使用系统代理设置 - "自动":自动检测代理设置 - " config-url":自动代理配置URL - "袜子" - "袜子5" - " http" - /null/undefined
有答案,"手动"不是可能的选择之一,您可以使用" http"