【发布时间】:2014-09-04 01:12:20
【问题描述】:
我想使用fs 库在我的脚本开头创建一个文件并在结尾删除它。 cookies.txt 文件在脚本开始时创建,但在脚本结束时不会被删除..
phantom.cookiesEnabled = true;
var fs = require('fs');
var cookies = JSON.stringify(phantom.cookies);
fs.write("cookies.txt", cookies, 777); // THIS WORKS !!
casper.start('http://google.fr/', function(){
this.viewport(320, 480);
});
// my script ....
casper.then(function(){
fs.remove("cookies.txt"); // THIS NOT WORKS !!
});
casper.run(function() {
this.test.done();
this.exit();
});
我写的启动脚本的命令
casperjs test lbc.js --cookies-file=cookies.txt --web-security=no
【问题讨论】:
标签: javascript file phantomjs casperjs fs