我正在以特定的时间间隔向文件写入内容,并且我将该文件的数据发送到我的邮件。
所以我的命令是,
var html = '';
res.on('data', function(chunk){
html+=chunk;
});
res.on('end',function(){
var $ = cheerio.load(html);
var commonTitles = [];
var commonArtists = [];
commonTitles.push($.text($('p.title').eq(0)));
commonTitles.push($.text($('p.title').eq(1)));
commonTitles.push($.text($('p.title').eq(2)));
commonTitles.push($.text($('p.title').eq(3)));
commonTitles.push($.text($('p.title').eq(4)));
commonArtists.push($.text($('p.artist').eq(0)));
commonArtists.push($.text($('p.artist').eq(1)));
commonArtists.push($.text($('p.artist').eq(2)));
commonArtists.push($.text($('p.artist').eq(3)));
commonArtists.push($.text($('p.artist').eq(4)));
console.log(
'The 5 most recently played titles: \n' +
commonTitles[0] + ' / ' + commonArtists[0] + '\n' +
commonTitles[1] + ' / ' + commonArtists[1] + '\n' +
commonTitles[2] + ' / ' + commonArtists[2] + '\n' +
commonTitles[3] + ' / ' + commonArtists[3] + '\n' +
commonTitles[4] + ' / ' + commonArtists[4]
);
})
但这会提供所有文件内容。如何获取文件的新添加/最后附加数据?
这可能吗?