【问题标题】:Atom/RSS feed reading doesn't show all nodes [Found-and-Closed]Atom/RSS 提要阅读不显示所有节点 [Found-and-Closed]
【发布时间】:2013-11-21 13:52:15
【问题描述】:

我有以下 RSS 提要。当我使用FeedziraSimple-rssRSS Parser 逐一解析这个提要时,我遇到了类似的问题,对于这个 RSS 中的 item 节点,它只是显示 titledescription,但跳过 urlid 个节点。

<rss xmlns:content="![CDATA[http://purl.org/rss/1.0/modules/content/]]" version="2.0">
<parsererror style="display: block; white-space: pre; border: 2px solid #c77; padding: 0 1em 0 1em; margin: 1em; background-color: #fdd; color: black">
<h3>This page contains the following errors:</h3>
<div style="font-family:monospace;font-size:12px">
error on line 1 at column 63: xmlns:content: '![CDATA[http://purl.org/rss/1.0/modules/content/]]' is not a valid URI
</div>
<h3>
Below is a rendering of the page up to the first error.
</h3>
</parsererror>
<channel>
<title>
<![CDATA[ Leonardo Hotels ]]>
</title>
<link>
<![CDATA[ http://www.leonardo-hotels.mobi ]]>
</link>
<description>
<![CDATA[ All Leonardo Hotels ]]>
</description>
<copyright>
<![CDATA[ Copyright 2013, Silvertravel.co.il ]]>
</copyright>
<ttl>20</ttl>
<lastBuildDate>
<![CDATA[ Thu, 21 Nov 2013 11:34:38 EST ]]>
</lastBuildDate>
<item>
<content:lang>
<![CDATA[ eng ]]>
</content:lang>
<content:id>
<![CDATA[ 16 ]]>
</content:id>
<title>
<![CDATA[ Leonardo Suite Hotel Tel Aviv-Bat Yam ]]>
</title>
<description>
<![CDATA[
Located directly at the beach, the Leonardo Suite Hotel Tel Aviv-Bat Yam offers 108 ]]>
</description>
<content:url>
<![CDATA[
http://www.leonardo-hotels.mobi/octopus/Upload/Images/Resorts/batyam deluxe livingroom 255.jpg
]]>
</content:url>
</item>
.
.
.
<item> ...</item>
<item> ...</item>

为了更深入地了解这个问题,这是每个解析器的代码:

用于 RSS 解析器

url = 'http://www.leonardo-hotels.mobi/rss.aspx?lang=eng'
url, timeout =  feed_url.strip, 60
uri = URI.parse(URI.encode(url))
http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout, http.read_timeout = timeout, timeout
http.request_get(uri.request_uri) do |response|
  data = RSS::Parser.parse(response.read_body, false, false)
    puts data.channel.item.inspect
    return data.channel.items
end

对于简单的 RSS

url = 'http://www.leonardo-hotels.mobi/rss.aspx?lang=eng'
rss = SimpleRSS.parse open(url)
puts rss.channel.items.first

Feedzira

url = 'http://www.leonardo-hotels.mobi/rss.aspx?lang=eng'
rss = Feedzirra::Feed.fetch_and_parse(url)
puts rss.entries.first.inspect

问题是它没有显示所有节点的子数据。

【问题讨论】:

    标签: ruby-on-rails rss feed atom-feed rss-reader


    【解决方案1】:

    我发现上面提到的三个解决方案运行良好,实际上问题出在提供的 RSS 提要中。

    我是如何知道我上面的代码运行良好的?

    我以下面的提要 url 作为测试样本,并在这个 url 上运行我的代码。事情非常棒。然后我才知道客户的 RSS 提要不符合标准。 http://feeds.feedburner.com/railscasts

    注意:

    我没有从这里删除问题,因为它为在这种特定情况下需要帮助的任何人提供了很好的信息。

    Feedzira 安装帮助

    How I installed Feedzira

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 2010-10-04
      • 2012-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      相关资源
      最近更新 更多