【问题标题】:casperjs unable to download CSV from APEX applicationcasperjs 无法从 APEX 应用程序下载 CSV
【发布时间】:2018-05-18 16:38:46
【问题描述】:

我正在尝试从 APEX 应用程序自动下载 CSV 文件。

var casper = require('casper').create({verbose: true, logLevel: "debug", viewportSize: { width: 1600, height: 400 } });
var url = "https://example.com"
casper.start(url);

casper.then(function () {
this.fill('#wwvFlowForm', {'P101_USERNAME': 'user', 'P101_PASSWORD': 'password'}, false);
});

casper.then(function () {
   this.click('#P101_LOGIN');
}).wait(5000).then(function () {
   this.echo('downloading file');
   this.download('https://example/apex/f?p=1002:173:10072525691961:CSV','report.csv')
});

casper.run();

我可以登录,但是当我尝试下载文件时,我得到了登录页面 html。 我尝试过使用 getBase64 方法,结果相同。 casper.download 是否使用不同的会话? 下载前后的截图显示我已经登录了。

【问题讨论】:

    标签: casperjs apex


    【解决方案1】:

    问题是这个 apex 应用在 url 中使用 instance_id,所以工作代码是:

    var casper = require('casper').create({verbose: true, logLevel: "debug", 
    viewportSize: { width: 1600, height: 400 } });
    var url = "https://example.com"
    casper.start(url);
    
    casper.then(function () {
    this.fill('#wwvFlowForm', {'P101_USERNAME': 'user', 'P101_PASSWORD': 'password'}, false);
    });
    casper.then(function () {
        this.click('#P101_LOGIN');
    }).wait(5000).then(function () {
       this.echo('downloading file');
       var instance_id = this.getCurrentUrl().split(':')[3];
       var download_url = url + '/apex/f?p=1002:173:' + instance_id;
       this.download('download_url' + ':CSV','report.csv')
    });
    
    casper.run();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-23
      • 1970-01-01
      • 1970-01-01
      • 2012-05-22
      • 2012-04-10
      • 2015-12-17
      • 1970-01-01
      • 2016-01-29
      相关资源
      最近更新 更多