search

Home  >  Q&A  >  body text

node.js - 请问phantom-proxy如何设置代理ip

现在有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中?

伊谢尔伦伊谢尔伦2873 days ago715

reply all(2)I'll reply

  • PHPz

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

    Supplement, use 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

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:22:01

    http://www.haoservice.com/docs/39 This is the interface of ip proxy

    reply
    0
  • Cancelreply