LoginSignup
9
9

More than 5 years have passed since last update.

PhantomJS/CasperJS でファイル操作

Posted at

PhantomJS/CasperJs でローカルのファイルを操作するには fs module を使います。Node の fs module とは違う同期 API です。

リファレンス によれば CommonJS Filesystem proposal を基に作られてるとか。

例えば、あるディレクトリの中身を列挙するには以下のようにします。

var fs = require('fs');

var files = fs.list(fs.workingDirectory + '/data');
files.forEach(function (file) {
  console.log(file);
});

Node の fs module の readdirSync() と違い、... を含めた結果が返ってきます。

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9