Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Proxy in phantomjs

I tried it

phantomjs --proxy=ip:port example.js

var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
    console.log(msg);
};
page.onLoadFinished = function(status){
    if (!status){
        console.log('fail');
        phantom.exit();
    }
    page.render("1.png");
    phantom.exit();
};
page.open("http://example1.net/");
page.open("http://example2.net/");

but I want to go through proxy for example1.net only I don't want for example2.net

How can I solve it?

like image 836
freddiefujiwara Avatar asked Mar 22 '23 00:03

freddiefujiwara


1 Answers

PhantomJS has a

setProxy(ip, port [, proxyType = 'http', user, password])

method to do this dynamically. See https://github.com/ariya/phantomjs/pull/11829. Other proxy type is socks5.

like image 198
ss1 Avatar answered Mar 31 '23 11:03

ss1