我对 Ruby 真的很陌生(第一天!),我在这里苦苦挣扎。我正在尝试结合 Typhoeus 构建一个 rss 解析器,因为我正在解析 100 多个提要,并且还因为我想让它工作。
这就是我的代码:
require 'typhoeus'
require 'feedzirra'
feed_urls = ["feed1", "feed2"]
hydra = Typhoeus::Hydra.new
feeds = {}
entry = {}
feed_urls.each do |feed|
r = Typhoeus::Request.new(feed)
r.on_complete do |response|
feeds[r.url] = response.body
feeds[r.url] = Feedzirra::Feed.parse(response.body)
entry = feeds.entries.each do |entry|
puts entry.title
end
hydra.queue r
end
end
hydra.run
我确定这是一些语法问题。我仍然有一些困难时期。例如,;
尽管我在编写 PHP 时总是忘记它,但我总是保持关闭行。那么,也许有人可以帮忙?在没有台风的情况下获得饲料结果并不难。
编辑:
>> puts feeds.entries.inspect
[["http://feedurl", #<Feedzirra::Parser::AtomFeedBurner:0x1023b53f0 @title="Paul Dix Explains Nothing", @entries=[#<Feedzirra::Parser::AtomFeedBurnerEntry:0x1023b05d0 @published=Thu Jan 13 16:59:00 UTC 2011, @author="Paul Dix", @summary="Earlier this week I had the opportunity to sit with six other people from the NYC technology scene and talk to NYC Council Speaker Christine Quinn and a few members of her staff. Charlie O'Donnell organized the event to help...", @updated=Thu Jan 13 17:55:31 UTC 2011, @title="Water water everywhere and not a drop to drink: The Myth and Truth of the NYC engineer shortage", @entry_id="tag:typepad.com,2003:post-6a00d8341f4a0d53ef0148c793f692970c", @content="....
所以,我至少得到了一些东西。