Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
download all public tweets of a twitter user
var http = require('http'),
querystring = require('querystring'),
fs = require('fs');
var screenname = '5000lobsters';
fs.mkdirSync(process.cwd() + '/tweets');
var getTweets = function(screenname, page) {
page = page || 0;
var query = {
screen_name: screenname,
page: page,
include_rts: false,
trim_user: true
};
var options = {
host: 'api.twitter.com',
port: 80,
path: '/1/statuses/user_timeline.json?' + querystring.stringify(query)
};
http.get(options, function(res) {
res.setEncoding('utf8');
var body = '';
res.on('data', function(data) {
body += data;
});
res.on('end', function() {
var tweets = JSON.parse(body);
if (!tweets.length) {
return;
}
tweets.forEach(function(tweet) {
var path = [process.cwd(), 'tweets', tweet.id_str + '.json'].join('/');
console.log
fs.writeFileSync(path, JSON.stringify(tweet));
});
getTweets(screenname, page + 1);
});
});
};
getTweets(screenname);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.