Last active
May 20, 2016 15:33
-
-
Save apricoton/a33f962b3cf1c66003727a48b6d2c6b5 to your computer and use it in GitHub Desktop.
Twitterの「全ツイート履歴」に入っている月別JavaScriptファイルから1つのJSONを作るスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
path = require('path'); | |
var output_filename = 'tweets.json'; | |
var js_dir = path.join('data', 'js', 'tweets'); | |
var Grailbird = { | |
data: {}, | |
}; | |
fs.readdirSync(js_dir).forEach(function (file) { | |
var filepath = path.join(js_dir, file); | |
console.log('reading : ' + filepath); | |
var data = fs.readFileSync(filepath, 'utf8'); | |
eval(data); | |
}); | |
var tweets = []; | |
Object.keys(Grailbird.data).forEach(function (key) { | |
console.log('processing : ' + key); | |
tweets = tweets.concat(Grailbird.data[key]); | |
}); | |
console.log('convert to json'); | |
fs.writeFileSync(output_filename, JSON.stringify(tweets), 'utf8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment