现在有IP如下:192.168.2.45:8088
使用phantomjs 在cli下设置代理IP,可以如下phantomjs --proxy=192.168.2.45:8088 simple.js
现在,我希望在node中直接使用代理,我知道这个plugin
https://github.com/sheebz/phantom-proxy
请问使用phantom-proxy,node中直接设置代理IP,而不是在cli中设置?
或者是如何使用phantom,在node中直接设置代理IP,而不是在cli中?
PHPz2017-04-17 11:22:01
Use phantom
(module address) This module can meet your requirements.
var phantom = require('phantom');
phantom.create('--proxy=192.168.2.45:8088', function (ph) {
ph.createPage(function (page) {
page.open('http://....', function (status) {
//...
//...
ph.exit();
});
});
});
phantom-proxy
I just took a look at the document of phantom-proxy
. The author has reserved an interface for setting the proxy, but it has not been implemented yet. Here is a piece of his code:
//may integrate in future
var defaultoptions = {
...
'proxy': '0',
...
};
For the complete code, see https://github.com/sheebz/phantom-proxy/blob/master/lib/proxy.js#L42