【问题标题】:IronWorker, CasperJS and cookies supportIronWorker、CasperJS 和 cookie 支持
【发布时间】:2015-01-20 00:40:00
【问题描述】:

我使用 Ironworker 和 casperjs 完成了所有工作,但我还有一个步骤失败了:在此设置中启用 cookie 支持。

我正在使用 --cookies-file=cookies.txt 参数启动 casper,并且 cookies.txt 文件使用正确的权限进行了 chmod,但是当我访问测试页面并对其进行截图时不知何故没有 cookie 支持。

知道如何使用 IronWorker 启用此功能吗?

【问题讨论】:

    标签: phantomjs casperjs ironworker


    【解决方案1】:

    基于casperjs 示例但没有pha​​ntomjs(它已经包含在phantom-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"
    

    运行.sh:

    casperjs/bin/casperjs --verbose --ignore-ssl-errors=yes --ssl-protocol=any --cookies-file=cookies.txt simple.js
    

    simple.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();
    

    【讨论】:

      猜你喜欢
      • 2015-04-15
      • 2014-01-21
      • 2010-11-06
      • 2012-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      相关资源
      最近更新 更多