为什么 Ruby RSS 不从 Wordpress RSS 检索整个提要?
我用 Ruby 编写了一些简短的代码来使用来自 Wordpress 的 RSS 提要。一个简单化的版本看起来像这样:
require 'rss'
@rss = RSS::Parser.parse(open('http://blog.allbouttexas.com/feed/').read, false).items[0..3]
@rss.each do |rss|
puts rss.dc_creator
end
这很好用,然后,当我部署到我的生产服务器并执行它时,我得到:
undefined method 'dc_creator'
我对此有点困惑并做了一些调试。看起来,当在生产服务器上检索 RSS 提要时,并非所有元素都包含在 @rss
对象中。另一个未包含的元素是 content_encoded
。
然后,我通过将包含内容修改为以下内容来更改我的本地副本:
require 'rss/2.0.
执行此操作后,我得到与生产时相同的错误。看来我的 RSS 版本不同。
此外,经过研究,RSS 库似乎无法访问都柏林核心元素。试图弄清楚如何通过 RSS 访问这些元素。
I wrote a quick bit in Ruby to consume an RSS feed from Wordpress. A dumbed down version looks like this:
require 'rss'
@rss = RSS::Parser.parse(open('http://blog.allbouttexas.com/feed/').read, false).items[0..3]
@rss.each do |rss|
puts rss.dc_creator
end
This works great, then, when I deployed to my production server and executed it, I got:
undefined method 'dc_creator'
I am a little boggled by this and did some debugging. It appears that when the RSS feed is retrieved on the production server, not ALL elements are included in the @rss
object. Another element not included is content_encoded
.
I then changed my local copy by modifying the include to this:
require 'rss/2.0.
After doing this, I get the same error as on production. Appears that my versions of RSS are different.
Also, after research, it appears that the RSS libraries do not have access to Dublin Core elements. Trying to figure out how to access these elements via RSS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论