Skip to content

Instantly share code, notes, and snippets.

@zmaril
Forked from tcr/debate-twitter-stream.js
Created October 17, 2012 04:29
Show Gist options
  • Save zmaril/3903705 to your computer and use it in GitHub Desktop.
Save zmaril/3903705 to your computer and use it in GitHub Desktop.
See a streaming list of all tweets concerning the presidential debate.
// 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','rmoney']
}, 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