0
解析RSS提要時出現問題。 當我這樣做:Ruby獲取RSS提要將無法獲得最新的提要
feed = getFeed("http://example.com/rss)
如果飼料含量的變化是不更新。
如果我不喜歡這樣寫道:
feed = getFeed("http://example.com/rss?" + Random.rand(20).to_s)
它工作的大部分時間,但並非總是如此。
getFeed()
實現這樣的:
def getFeed(url)
rss_content = ""
open(url) do |f|
rss_content = f.read
end
return rss_content
end
我用這個在西納特拉和Ruby 1.9.3,如果有所作爲。 在我看來它被緩存的地方,但我不知道在哪裏。
編輯: Okey在服務器上運行1/2天后出現問題。
此之前的討論可能會有所幫助:http://stackoverflow.com/questions/6389255/rss-feed-how-to -recommend-an-update-interval – fmendez 2013-02-23 16:28:14
不確定,因爲這意味着open()檢查這個,我不這麼認爲 – 2013-02-23 16:32:40