Skip to content

Instantly share code, notes, and snippets.

@ebuildy
Created December 31, 2013 11:49
Show Gist options
  • Save ebuildy/0b5023e2d97ebc2e4a57 to your computer and use it in GitHub Desktop.
Save ebuildy/0b5023e2d97ebc2e4a57 to your computer and use it in GitHub Desktop.
var feedparser = require('feedparser'),
request = require('request'),
Iconv = require('iconv').Iconv;
parseNext();
function parseNext(){
var url = "http://fr.canoe.ca/rss/feed/nouvelles/aujourdhui.xml";
var charset = 'iso-8859-1';
var iconv = new Iconv(charset, 'utf-8');
var req = {
uri: url,
headers: {
'user-agent' : 'Qwantify/1.0'
},
timeout: 10000,
followAllRedirects : true,
encoding : null
};
var actualCharsetEncoding = null;
request(req)
.pipe(new feedparser())
.on('error', function (error) {
console.error(error);
})
.on('meta', function (meta) {
console.log(meta);
console.log('===== %s =====', meta.title);
actualCharsetEncoding = meta['#xml']['encoding'];
})
.on('readable', function()
{
var stream = this, item;
while (item = stream.read())
{
console.log('Got article: %s', item.title || item.description);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment