如何在rails 3.1中解析rss

时间:2022-09-11 00:13:53

How should I go about parsing rss feeds in a rails 3.1 app. Having trouble finding current resources on this topic.

我应该如何在rails 3.1 app中解析rss feed。无法找到有关此主题的当前资源。

2 个解决方案

#1


1  

You'll need this in your controller:

你需要在控制器中使用它:

require 'rss'
rss = RSS::Parser.parse(open('http://example.com/feed/posts').read, false)

From Parsing an RSS feed with Ruby.

从使用Ruby解析RSS提要。

#2


0  

I'd recommend to use gem called Feedzirra

我建议使用名为Feedzirra的宝石

require 'feedzirra'

# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://www.knews.kg/ru/politics/rss/")

# feed and entries accessors
feed.title                  # => "Политика » K-News: Новости страны"
feed.description            # => "Политика страны"

while installing (Ubuntu 12.04) i had problem with compiling, try this

虽然安装(Ubuntu 12.04)我有编译问题,试试这个

sudo apt-get install libcurl4-gnutls-dev

sudo apt-get install libcurl4-gnutls-dev

#1


1  

You'll need this in your controller:

你需要在控制器中使用它:

require 'rss'
rss = RSS::Parser.parse(open('http://example.com/feed/posts').read, false)

From Parsing an RSS feed with Ruby.

从使用Ruby解析RSS提要。

#2


0  

I'd recommend to use gem called Feedzirra

我建议使用名为Feedzirra的宝石

require 'feedzirra'

# fetching a single feed
feed = Feedzirra::Feed.fetch_and_parse("http://www.knews.kg/ru/politics/rss/")

# feed and entries accessors
feed.title                  # => "Политика » K-News: Новости страны"
feed.description            # => "Политика страны"

while installing (Ubuntu 12.04) i had problem with compiling, try this

虽然安装(Ubuntu 12.04)我有编译问题,试试这个

sudo apt-get install libcurl4-gnutls-dev

sudo apt-get install libcurl4-gnutls-dev