2013-11-21 39 views
-1

我有以下RSS提要。当我通过一个解析使用FeedziraSimple-rss这种饲料由RSS Parser一个,我面临着类似的问题,即项目在这个RSS节点,它只是显示标题描述,但跳过url and id nodes。Atom/RSS提要阅读不显示所有节点[Found-and-Closed]

<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 

的问题是,它没有显示所有节点儿童的数据。

回答

0

我发现上面提到的三种解决方案实际上完美地工作,实际上问题出现在提供的RSS源中。

我是怎么知道我的上面的代码工作完美?

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

注:

我没有在此处被拆除的问题,因为它包含的人谁需要帮助,在这种特殊情况下很好的信息。

对于Feedzira安装帮助

How I installed Feedzira