如何在casperjs代码中设置代理
how to set proxy in casperjs code
这里有一些我已经尝试过的选项,但是 none 对我有用
有什么办法可以在我们访问任何特定网站之前更改代理?
var casper = require("casper").create({
setProxy: "proxy here",
// --proxy: "proxy here",
webSecurityEnabled: false,
verbose: true,
logLevel: "debug",
waitTimeout: 100000,
pageSettings: {
userAgent: "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0",
proxy: 'proxy here'
}});
var url = 'http://whatismyipaddress.com/';
var fs = require('fs');
var path = 'ip_check.txt';
casper.start(url, function() {
casper.cli.options["proxy"] = "proxy here";
var js = this.evaluate(function() {
return document;
});
fs.write(path,js.all[0].outerHTML,'w');
});
casper.run();
您可以像这样发送代理参数
casperjs --proxy="switchproxy.proxify.net:7498" xyz.js
这里有一些我已经尝试过的选项,但是 none 对我有用
有什么办法可以在我们访问任何特定网站之前更改代理?
var casper = require("casper").create({
setProxy: "proxy here",
// --proxy: "proxy here",
webSecurityEnabled: false,
verbose: true,
logLevel: "debug",
waitTimeout: 100000,
pageSettings: {
userAgent: "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0",
proxy: 'proxy here'
}});
var url = 'http://whatismyipaddress.com/';
var fs = require('fs');
var path = 'ip_check.txt';
casper.start(url, function() {
casper.cli.options["proxy"] = "proxy here";
var js = this.evaluate(function() {
return document;
});
fs.write(path,js.all[0].outerHTML,'w');
});
casper.run();
您可以像这样发送代理参数
casperjs --proxy="switchproxy.proxify.net:7498" xyz.js