Created
October 17, 2012 04:24
-
-
Save tcr/3903698 to your computer and use it in GitHub Desktop.
See a streaming list of all tweets concerning the presidential debate.
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
// npm install rem read clarinet | |
var rem = require('rem'); | |
var read = require('read'); | |
var clarinet = require('clarinet'); | |
// Create Twitter API, prompting for key/secret. | |
var tw = rem.load('twitter', 1.0).prompt(); | |
// Authenticate user via the console. | |
rem.console(tw, function (err, user) { | |
// Pass the statuses/sample stream to a JSON parser and print only the tweets. | |
user.stream('statuses/filter').post({ | |
track: ['obama', 'romney', 'debate'] | |
}, function (err, stream) { | |
stream.pipe(clarinet.createStream()).on('key', function (key) { | |
if (key == 'text') { | |
this.once('value', function (tweet) { | |
console.log(String(tweet)); | |
}) | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment