RSS Parsing with Webscript

As I mentioned in a blog post yesterday, Webscript now has built-in support for parsing XML. Among other things, this makes it easy to parse RSS feeds. To make that even easier, we've brought the excellent feedparser module into our library.

Here's a simple script that parses an RSS feed and returns the parsed result as JSON. This code is also available as an example on our examples page.

local feedparser = require('feedparser')
local response = http.request {
        url = request.query.feed or 'http://blog.webscript.io/rss.xml'
}
local parsed = feedparser.parse(response.content)
return parsed

To get a better feel for the structure returned by feedparser, you may also want to take a look at another example, Generating HTML From a Template, which converts an RSS feed to a simple HTML page.