-1
我有以下RSS提要。當我通過一個解析使用Feedzira,Simple-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
的問題是,它沒有顯示所有節點兒童的數據。