CasperJS文件在30秒后下载时间

Mat*_*t C 5 phantomjs casperjs

我正在使用CasperJS下载15 MB的文件.在浏览器中,下载大约需要3分钟才能完成.使用Casper,.download相同url 的函数在30秒后返回,并且写入磁盘的文件为0字节.我已经尝试设置更长的超时时间:

var casper = require("casper").create({
    pageSettings: {
        webSecurityEnabled: false
    },
    waitTimeout: 500000,
    stepTimeout: 500000
});
Run Code Online (Sandbox Code Playgroud)

但它们没有效果.这是我的下载功能:

casper.on('resource.received', function (resource) {
    var url, file;
    if ((resource.url.indexOf("myDownloadUniqueString=") !== -1) ) {
        this.echo(resource.url);  // the echo'ed url can be downloaded in a web browser
        url = resource.url;
        file = "downloaded_file.wav";  // this will be 0 bytes
        try {
            var fs = require("fs"); // phantom js file system (not node)
            casper.download(resource.url, file);
        } catch (e) {
            this.echo(e);  // no error is thrown
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?也许PhantomJS fs方法存在问题,但文档不完整......

Dar*_*ook 0

添加怎么样resourceTimeout

pageSettings: {
  webSecurityEnabled: false,
  resourceTimeout: 240000 //240s
},
Run Code Online (Sandbox Code Playgroud)

这个答案说它是在 PhantomJS 1.9 中添加的,但尚未记录。