Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of using feedparser ( with ES6 on node.js >= 4.0.0
'use strict'
const FeedParser = require('feedparser')
const request = require('request')
let req = request('')
let parser = new FeedParser()
req.on('error', (err) => {
// handle request error
req.on('response', (res) => {
// check if status code is not correct
if (res.statusCode !== 200) {
return req.emit('error', new Error('Bad status code'))
// if the res is correct, when can pipe the response
req.pipe(parser) // pipe response to feedparser
parser.on('error', (err) => {
// handle parser error
parser.on('end', () => {
// handle that we've finished reading articles
console.log('End parsing')
parser.on('readable', () => {
let item =
let meta = parser.meta // get the metadata of the feed
while (item) {
// do whatever you want with the item
// get the next item, if none, then item will be null next time
item =

This comment has been minimized.

Copy link
Owner Author

@midudev midudev commented Jan 25, 2016

Used Standard Style to code the gist:


This comment has been minimized.

Copy link

@marti1125 marti1125 commented Feb 3, 2016

nice =D nodejs support es6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.