全世界のツイートをリアルタイムに保存してごにょごにょするスクリプト
- 初期設定では日本でつぶやかれた位置情報つきツイートのStreamを取得し,保存します
- 含まれる文字列で検索するには,app.coffee 内の
# 'track': tracks
のコメントアウトを外してください
First of all, DON’T PANIC. It will take 5 minutes to get the gist of what this script is all about.
- You can install its dependencies with npm:
npm install
. - Get Your Twitter API Tokens and setup your API Keys to 'config/env.json'.
- Then run script! You can read all of the tweets from the all over the world via Streaming API and save it to mongoDB.
Please edit config/env.json
The keys listed below can be obtained from dev.twitter.com after setting up a new App.
{
"mongo": "mongodb://localhost/twitter",
"consumer_key": " Twitter ",
"consumer_secret": " API ",
"access_token_key": " Keys ",
"access_token_secret": " go here! "
}
Hello world.
# If you want to test script(Save tweets only when terminal launched).
$ coffee ./app.coffee
--- Connect successful ---
@high4_01_17 終末ヒロイン
@HandsNet \おハンズございます/ 今日も1日よろしくお願いします。
@kuji らむれ狩られるそうです
@iris_sfc 紅茶のみたい珈琲胃にくる(´つヮ⊂)
@sussaa_sfc 地下のファミマでぼったくられそうになった、パンとお茶で400円て、、
@tako0846 原稿を書く時間が確実に減ってるやばい
@gizmodejapan 【最新記事】 Androidのアクティブユーザー数、月10億人を突破 http://t.co/HhulkQJeDv
... (streaming)
# Run as a production daemon.
$ pm2 start processes/production.json
{ online: true, success: true, pid: 37877, pm2_version: '0.9.1' }
Process launched
┌──────────────┬────┬─────────┬───────┬────────┬───────────┬────────┬─────────────┬───────────┐
│ App name │ id │ mode │ PID │ status │ restarted │ uptime │ memory │ watching │
├──────────────┼────┼─────────┼───────┼────────┼───────────┼────────┼─────────────┼───────────┤
│ tweet-stream │ 0 │ cluster │ 37878 │ online │ 0 │ 0s │ 26.570 MB │ activated │
└──────────────┴────┴─────────┴───────┴────────┴───────────┴────────┴─────────────┴───────────┘
# Then you can see the daemon status.
$ pm2 status
$ pm2 logs