-
-
Save ebuildy/0b5023e2d97ebc2e4a57 to your computer and use it in GitHub Desktop.
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 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