var scraper = require('scraper');
scraper('http://hoge.com/hoge', function(err, $) {
// データを取得
if (err) {throw err;}
var ans = /<div>([0-9]*)<\/div>/ig.exec($('html').html());
if (ans === null || !ans[1]) { throw 'No match'; }
// 書き込みデータ作成
var dt = new Date();
var dtString = ("0" + dt.getHours()).slice(-2) + ':' + ("0" + dt.getMinutes()).slice(-2);
// ファイルへ保存
var fs = require('fs');
fs.appendFileSync("/temp/data.txt", dtString + "\t" + ans[1] + "\n");
});
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme