私はRubyに本当に慣れていません(初日です!)そして私はここでこれに苦労しています。100を超えるフィードを解析しているため、またそれを機能させたいため、Typhoeusと組み合わせてrss-parserを構築しようとしています。
これが私のコードです:
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を書くときはいつも忘れていますが、私は常に行を閉じ続けます。だから、多分誰かが助けることができますか?typhoeusなしでフィード結果を取得することはそれほど難しくありませんでした。
編集:
>> 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="....
だから、私は少なくとも何かを得る。