Last active
December 16, 2015 04:48
Parse twitter webpage saved locally, and output tweets in the correct reading order in the console (nodejs)
This file contains hidden or 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
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