Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy in phantomjs

I cant understand how to using proxies in phantomjs, i tried

phantomjs example.js --proxy="ip:port"

phantomjs example.js --proxy=ip:port

phantomjs example.js --proxy=ip:port --proxy-type=http

but i see only my ip=(

No any output, also if proxy ip apriori invalid.

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://whoer.net/");

what obvious thing i forgot? Thanks.

like image 426
Torv Avatar asked Jul 04 '12 19:07

Torv


1 Answers

As i said i forgot one obvious thing - arguments for phantomjs must be after command "phantomjs" not after script name. Correct variant:

phantomjs --proxy=ip:port example.js

like image 107
Torv Avatar answered Sep 22 '22 09:09

Torv