- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我真的是 Ruby 的新手(第一天!),我正在努力解决这个问题。我正在尝试结合 Typhoeus 构建一个 rss-parser,因为我正在解析 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="....
所以,我至少得到了一些东西。
最佳答案
您似乎在 on_complete block 内排队。您不应该在 feed_urls.each block 中排队吗?或者,也许您应该在完成所有请求后检查所有条目?像这样:
hydra = Typhoeus::Hydra.new
feeds = {}
entry = {}
feed_urls = ["feed1", "feed2"]
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)
end
hydra.queue r
end
hydra.run
feeds.entries.each do |feed|
puts "-- " + feed[1].title
feed[1].entries.each do |entry|
puts entry.title
end
end
关于 ruby 、Feedzirra、斑疹伤寒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312911/
试图让我的头脑围绕 Feedzirra 在这里。 我已完成所有设置和所有操作,甚至可以获得结果和更新,但发生了一些奇怪的事情。 我想出了以下代码: def initialize(feed_url)
我真的是 Ruby 的新手(第一天!),我正在努力解决这个问题。我正在尝试结合 Typhoeus 构建一个 rss-parser,因为我正在解析 100 多个提要,也因为我想让它正常工作。 这就是我的
为任何类型的提要提供一个解析器的想法很棒,我希望它对我有用。我一直在尝试让 feedzirra 解析原子提要。具体来说: http://pindancing.blogspot.com/feeds/po
我正在使用 Feedzirra 并尝试按发布日期对提要数据进行哈希排序。我没有收到错误或任何错误,只是没有排序。这是我的 Controller 中的代码: class ClassifiedsContr
我正在尝试安装 feedzirra 但我遇到了麻烦。 当我安装 Feedzirra 时,它会寻找 curb (0.7.18)。 我按照说明在 windows 上安装了 curb >gem instal
我是 Ruby on Rails 的新手。我对 Feed 解析感到很兴奋,但是当我安装 FeedZirra 时,我收到了这个错误。 我使用 Windows 7 和 Ruby 1.8.7。 请帮忙。提前
有没有办法解析提要的自定义元素?不是提要条目,提要的自定义元素。我知道有一种方法可以对条目执行相同的操作。喜欢, Feedzirra::Feed.add_common_feed_entry_eleme
以下代码来自 Feedzirra 的要点,用于从 RSS 提要中获取更新的内容: feed = Feedzirra::Feed.fetch_and_parse(feed_url) feed = Fee
我正在使用 Feedzirra 来解析我的 RSS 提要,它运行良好——在我的初始测试中,它的速度是 Feed Normalizer 的两倍。更重要的是,它有很好的包装器,可以检查提要中的更新条目。当
Bundler could not find compatible versions for gem "builder": In Gemfile: rails (= 3.1.1) depends on
这是我尝试解析的提要结构: title.. http://url … description... Tue, 20 Nov 2012 14:37:30 +0000 sk-SK h
我是一名优秀的程序员,十分优秀!