我完成了所有关于Ironworker和casperjs的工作,并且我还有一个失败的步骤:在这个设置中启用cookie支持。
我使用--cookies-file=cookies.txt param启动casper,cookies.txt文件具有正确的权限,但是当我访问测试页面并截取它时,不知怎么就没有cookie支持。
知道如何用IronWorker启用这个特性吗?
发布于 2015-01-20 08:23:15
基于卡珀尔示例,但没有幻影is (它已经包含在幻影-1.9堆栈中)
casper.worker:
runtime "binary"
stack "phantom-1.9"
exec "run.sh"
# Include the CasperJS library
dir "casperjs"
# Include the Javascript file that Casper will execute
file "simple.js"run.sh:
casperjs/bin/casperjs --verbose --ignore-ssl-errors=yes --ssl-protocol=any --cookies-file=cookies.txt simple.jssimple.js:
var casper = require('casper').create();
casper.userAgent('Mozilla/5.0 (X11; Linux i586; rv:31.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36')
casper.start('https://hud.iron.io/', function() {
this.fill('form[action="/sessions"]', { email: 'foo@bar.com', password: 'super_hard_pass' }, true);
this.click('input[name="commit"]');
this.echo(this.getTitle());
});
casper.wait('10000');
casper.thenOpen('https://hud.iron.io/account', function() {
this.echo(this.getTitle());
this.echo(this.evaluate(function() {return document.querySelector(".account-header").innerText}));
});
casper.run();https://stackoverflow.com/questions/28035986
复制相似问题