Proxy in phantomjs

╄→гoц情女王★ 提交于 2019-12-18 11:49:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!