问题
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.
回答1:
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
回答2:
This code is for authentication with username & password. As well as, save result in sample.txt:
phantomjs --proxy=Ip:Port --proxy-auth=User:Pass App.js > sample.txt
来源:https://stackoverflow.com/questions/11334681/proxy-in-phantomjs