Created
January 21, 2019 22:00
-
-
Save cabelotaina/67ccf15388b7ecd47e54217e124f192e to your computer and use it in GitHub Desktop.
get folha de sao paulo rss via nodejs
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
var https = require('https'); | |
var xml2js = require('xml2js'); | |
var parser = new xml2js.Parser(); | |
parser.on('error', function(err) { console.log('Parser error', err); }); | |
var data = ''; | |
https.get('https://feeds.folha.uol.com.br/emcimadahora/rss091.xml', function(res) { | |
if (res.statusCode >= 200 && res.statusCode < 400) { | |
res.setEncoding("binary"); | |
res.on('data', function(data_) { data += data_.toString(); }); | |
res.on('end', function() { | |
//console.log('data', data); | |
parser.parseString(data, function(err, result) { | |
console.log(err) | |
console.log(util.inspect(result, false, null)) | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment