Skip to content

Instantly share code, notes, and snippets.

@ragekit
Last active December 16, 2015 04:48
Show Gist options
  • Save ragekit/5379309 to your computer and use it in GitHub Desktop.
Save ragekit/5379309 to your computer and use it in GitHub Desktop.
Parse twitter webpage saved locally, and output tweets in the correct reading order in the console (nodejs)
var fs = require("fs");
var cheerio = require('cheerio');
fs.readFile('input.html','utf8', function (err, data) {
if (err) throw err;
var $ = cheerio.load(data);
$('.js-tweet-text').html();
var tweets = []
$('.js-tweet-text').each(function(index,element)
{
tweets[index] = $(this).text();
});
tweets.reverse();
var output = "";
for(var i = 0; i <tweets.length; i ++)
{
if(tweets[i][0] != "@")
{
output += tweets[i];
output += "\n";
}
}
console.log(output);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment