Parsing a RSS Feed
51 comments Latest by louis vuitton replica Tue, 31 Aug 2010 19:46:55 GMT
A friend was asking me how they could easily read a RSS feed and display the last x items in their rails project. This was my quick and dirty response.
require 'rss/2.0'
require 'open-uri'
class RssfeedController < ApplicationController
def index
feed_url = 'http://www.planetrubyonrails.org/xml/rss'
output = "<h1>My RSS Reader</h1>"
open(feed_url) do |http|
response = http.read
result = RSS::Parser.parse(response, false)
output += "Feed Title: #{result.channel.title}<br />"
result.items.each_with_index do |item, i|
output += "#{i+1}. #{item.title}<br />" if i < 10
end
end
render_text output
end
end
Is there an easier way to do this with another RSS library? I figured that the simplest method would be to just use the standard library that comes with Ruby.
Enjoying the content? Be sure to subscribe to my RSS feed.






blah blah blah. wanna buy some erection cream?
I found this googling for info on the simple-rss gem. Will try to write how I used it on http://ruby.vanhecke.info
Note: For this to work, you need to edit the last part of line 14. (It has an incorrectly encoded less-than sign between
if iand10.Here’s a version you can pop in you lib and call from your pages… cheers
Wow, I’ve been looking for this all day! Thank you!
i’m the type of guy that likes these kind of posts
thanks!
thanks!
thanks!
thanks!
Thanks Robby, really useful.
I refactored this to be more railsy:
In this case, the view (in haml) would be:
thanks for that quickie :)
Can I get a link for that erection cream?
how to parser RSS with Ajax on Rails?
Not to be grammatically picky, but one would say ‘an RSS feed’ as the pronunciation of letter R starts with a vowel sound.
Otherwise, a useful titbit, thanks :)
More than useful, small, dry, working. Thanks for that piece.
Cheers, Jason
The post is excellent, the comments make it even more usefull. Did you know you are nice guys ? :-)
Hi, this is very useful.
I will had to add some rescue statements for what I want to do, but this is a good start.
Thank you!
this can also be done with acts_as_feed http://github.com/grosser/acts_as_feed , which will represent the feed as feed model or as addition to a model, and parsing can be offloaded to a background process.
Just a quick update. The last line
posts[0..length – 1] if posts.size > length
will only return posts if the rss returns a number of posts > length otherwise it returns nil
posts.size > length ? posts[0..length – 1] : posts
should be used to return all posts when the total available posts is less the length
Thanks a lot.
Wholesale Clothing
More than useful, small, dry, working. Thanks for that piece.
Wholesale Brand Name Clothing
The post is excellent, the comments make it even more usefull. Did you know you are nice guys ? :-)
Wholesalers
Thanks for giving this solution. I’ve Bookmarked this page for future reference. auto parts warehouse
I like your quick and dirty response. In fact, I like quick and dirty little codes myself. I just try to polish things once I think I got the work perfected, or something like that.
adult reviews
I agree with Clement. What makes this post even more interesting and even more helpful are the several comments that follow that try to improve on the code. It is like research made easy. Thanks.
pornhub
I wish I am posting a comment as a contributor. As for now, I would really want updates from those who posted previous comments on what is really the best way to go about parsing RSS feeds.
singles online
十字傷|秋冬之點滴|寫作本真|樂在讀書|我在北方|祭文化|121.entry”>四月薔薇花開|嘴臉|慎終追遠 |133.entry”>清明節的風景|
ygb5aihk.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ æíäßÓ mgbbb9azi.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÈÇÑÈí mgbk1eh0a.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ãßíÇÌ ngbmz.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ØÈÎ ngbd2a7d5a.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÊáÈíÓ —ymcabdbp8cl6d9f.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÈÑÇÊÒ mgbbh4i.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÈäÇÊ games ugbg7cp.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÏæáÒ —-ctdbabng3drm3n5arubl2cg.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ãÔÇåíÑ mgb0azbm.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÝáÇÔ mgbaj0ai2l.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÓíÇÑÇÊ æ ÓÈÇÞ ugbe7cuai.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ Ïíᑥ ÈäÇÊ ngbda1a0k.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÊÑÊíÈ ÇáÛÑÝ —-ctdabbn2a8ane4ofb6a5g.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÊáÈíÓ ÝÓÇÊíä ÇÝÑÇÍ æ ÒÝÇÝ —ymcabebh7b7b4jtb6a.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÊáÈíÓ ÇæáÇÏ mgbu2doj.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ãÇÑíæ ygb6aihl.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ Óæäíß pgbn7coj.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ßÑÊæä mgba1czbq.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÇØÝÇá mgb0a6bn.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÇßÔä ÇÎÈÇÑ ÇáãÑÇÉ ÊÏÈíÑ ãäÒáì ÊÑÝíå ÚÇáã ÇáÍíÇÉ ÇáÒÒæÌíÉ ãáÇÈÓ ÇØÝÇá ÞãÕÇä äæã äÕÇÆÍ ØÈÎ ÇØÈÇÞ ÓÑíÚÉ ãÚÌäÇÊ ÔæÑÈÇÊ ÇáÚÇÈ ÈäÇÊ ÓÇäÏæÊÔÇÊ Ïíᑥ áÝÇÊ ØÑÍ áÝÇÊ ÍÌÇÈ ÚÇáã ÍæÇÁ ÑíÌíã æÑÔÇÞÉ ãØÈÎ ÍæÇÁ ÇÒíÇÁ ÍäÇÁ ÚØæÑ ãíß ÇÈ ÕæÑ ÞÕÕ ÇÓÚÇÑ ÇáÐåÈ æÙÇÆÝ ÝíÏíæ ÇÊíßíÊ ÝÓÇÊíä ãÍÌÈÇÊ ÇÒíÇÁ ÇßáÇÊ ÍáæíÇÊ ÇáØÈ ÇáÈÏíá æÇáÇÚÔÇÈ ÕÍÉ ÇáãÑÇÉ ÇáÚÑæÓ ÇßÓÓæÇÑÇÊ ãßíÇÌ Ïíᑥ ÚÕÇÆÑ æ ãÔÑæÈÇÊ ÊÝÓíÑ ÇáÇÍáÇã ØÈÎ ÇáÚäÇíÉ ÈÇáÇÒæÇÌ ÇáÚÇÈ ÈäÇÊ ÇáÚäÇíÉ ÈÇáÔÚÑ æÇáÈÔÑÉ ÕÍÉ ÇáãÑÇÉ ÒæÇÌ ÞãÕÇä äæã ÇáËÞÇÝÉ ÇáÌäÓíÉ ÚÈÇíÇÊ Ïíᑥ ÇáÚÇÈ mgbajgnm.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÏÑÇÌÇÊ æ ÏÈÇÈÇÊ mgbewv2hc.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÑíÇÖíÉ ÑíÇÖÉ mgbeb9gm0b.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÞÊÇá – ÇáÚÇÈ ÍÑßå softutopia ngbd7a2ek.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÊÕæíÈ æäÔÇä wgb8aq.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ æÑÞ æ ÐÇßÑÉ mgbb5aye.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÈÇÒá æ ãÊÇåÇÊ ngbckq0k.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÍÑÈíÉ æ ÚÓßÑíÉ mgbad0esc.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ãÊäæÚÉ —ymcajdt9bt7g1adr.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ÝáÇÔÇÊ ãÖÍßÉ ÇáÚÇÈ ÇØÝÇá ÝÞØ ÇáÚÇÈ ÍÑÈíÉ ÇáÚÇÈ ÑíÇÖíÉ ÇáÚÇÈ ãÊäæÚå ÇáÚÇÈ ÇßÔä ÞÊÇáíÉ ÇáÚÇÈ ÈäÇÊ ÇáÚÇÈ ÐßÇÁ ÇáÚÇÈ ÓíÇÑÇÊ ÇáÚÇÈ ÇáÚÑæÓÉ Óíæ ÏæáÒ ÇáÚÇÈ ÈÇÑÈí barbie ÇáÚÇÈ ÈÑÇÊÒ ÇáÚÇÈ ÊáÈíÓ ÇáÚÇÈ Ïíᑥ ÇáÚÇÈ ØÈÎ ÇáÚÇÈ ÞÕ ÇáÔÚÑ ÇáÚÇÈ ãÔÇåíÑ ÇáÚÇÈ ãßíÇÌ ÇáÚÇÈ åÇäÇ ãæäÊÇäÇ ÇáÚÇÈ Êáæíä ÇáÚÇÈ ÍíæÇäÇÊ ÇáÚÇÈ ÏíÒäì ÇáÚÇÈ ÓæÈÑ ãÇÑíæ æ Óæäíß ÇáÚÇÈ ßÑÊæä æ Çäãì ÇÝáÇã æ ãÓáÓáÇÊ ÇáÚÇÈ ÇæáÇÏ ÇáÚÇÈ ÇáÛÇÒ ÇáÚÇÈ ÐÇßÑÉ æ æÑÞ ÇáÚÇÈ ãÛÇãÑÇÊ æ ÇËÇÑÉ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/5%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%A8%D8%A7%D8%B1%D8%A8%D9%8A-1”>ÇáÚÇÈ ÈÇÑÈí —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/8%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%A7%D9%83%D8%B4%D9%86-%D9%88-%D9%85%D8%BA%D8%A7%D9%85%D8%B1%D8%A7%D8%AA-%D8%A8%D9%86%D8%A7%D8%AA-1”>ÇáÚÇÈ ÇßÔä æ ãÛÇãÑÇÊ ÈäÇÊ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/11%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%AF%D9%8A%D9%83%D9%88%D8%B1-%D9%88-%D8%AA%D8%B1%D8%AA%D9%8A%D8%A8-%D8%A7%D9%84%D8%BA%D8%B1%D9%81-1”>ÇáÚÇÈ Ïíᑥ æ ÊÑÊíÈ ÇáÛÑÝ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/15%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%AA%D9%84%D9%88%D9%8A%D9%86-%D8%B1%D8%B3%D9%88%D9%85-%D9%85%D8%AA%D8%AD%D8%B1%D9%83%D8%A9-1”>ÇáÚÇÈ Êáæíä ÑÓæã ãÊÍÑßÉ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/14%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%A7%D8%B2%D9%8A%D8%A7%D8%A1-%D9%88-%D9%81%D8%A7%D8%B4%D9%88%D9%86-%D9%88-%D9%85%D9%88%D8%B6%D8%A9-%D8%A7%D9%84%D8%AA%D9%84%D8%A8%D9%8A%D8%B3-1”>ÇáÚÇÈ ÇÒíÇÁ æ ÝÇÔæä æ ãæÖÉ ÇáÊáÈíÓ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/13%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D9%85%D8%B4%D8%A7%D9%87%D9%8A%D8%B1-1”>ÇáÚÇÈ ãÔÇåíÑ ÇáÚÇÈ ÌíãÒ ÈÑÇãÌ ÓæÝÊ ÈÑÇãÌ ÈÑÇãÌ ÇäÊÑäÊ æÔÈßÇÊ ÕæÑ æÓãÇíáÇÊ ãÇÓäÌÑ ÇÎÈÇÑ ãÓáÓáÇÊ ÇÌäÈíÉ ÇÝáÇã ÇÌäÈíÉ ÊÍãíá ÇÝáÇã ÊäÒíá ÈÑÇãÌ ËíãÇÊ ãæÈÇíá äÛãÇÊ ãæÈÇíá ÔÇÊ ÈÑÇãÌ ÇäÊÑäÊ æÔÈßÇÊ ãÕÇÑÚå ÍÑå ÈÑÇãÌ ßãÈíæÊÑ ÇÛÇäì ÇØÝÇá ÇÝáÇã ÕæÑ æÑãæÒ ãÇÓäÌÑ ÊÍãíá ÇáÚÇÈ ãÓÑÍíÇÊ ÇÝáÇã ßÑÊæä æÇäãì ÇÛÇäì ÇäÇÔíÏ íæÊíæÈ ÊæÈíßÇÊ ÑæãÇäÓíÉ ÊæÈíßÇÊ ÇÓáÇãíÉ ÈÑÇãÌ ÈæÑÊÇÈá portable ÇáÚÇÈ ÊæÑäÊ ãíÏíÇ æÇÚáÇäÇÊ ÇäÇÔíÏ ØíæÑ ÇáÌäÉ ÈáÇß ÈíÑì ÕæÑ ãÓÌÇÊ ÞÕÕ ÊæÈíßÇÊ ÑæãÇäÓíÉ ÊæÈíßÇÊ ÇÓãÇÁ ÇáÚÇÈ ÕÛíÑÉ ááÇØÝÇá ÊæÈíßÇÊ ÇÛÇäì ÊæÈíßÇÊ ÇÓáÇãíÉ ÕæÑ ÓíÇÑÇÊ ßÇÑíßÇÊíÑ ÕæÑ ÈäÇÊ ÚÇáã ÍæÇÁ ãßíÇÌ ÇÒíÇÁ ãØÈÎ Ïíᑥ ÇßÓÓæÇÑÇÊ ÇáÚäÇíå ÈÇáÔÚÑ æ ÇáÈÔÑå soft archive wgbh1d.xn—-ymcae0df5a6fo.com/”>ÕæÑ —ymcchcnva8ovbczg.xn—-ymcae0df5a6fo.com/”>ÊæÈíßÇÊ ÔãÓ ugb9awagb.xn—-ymcae0df5a6fo.com/”>ÝíÏíæ igbid0esc.xn—-ymcae0df5a6fo.com/”>ÇáÚÇÈ ãäÊÏì ÈÑÇãÌ ÓæÝÊ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/4%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%B7%D8%A8%D8%AE-1”>ÇáÚÇÈ ØÈÎ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/1%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D8%AA%D9%84%D8%A8%D9%8A%D8%B3-1”>ÇáÚÇÈ ÊáÈíÓ —ymcabdbp8i6dza.paramegsoft.com/GirlsGames/3%D8%A7%D9%84%D8%B9%D8%A7%D8%A8-%D9%82%D8%B5-%D8%A7%D9%84%D8%B4%D8%B9%D8%B1-1”>ÇáÚÇÈ ÞÕ ÇáÔÚÑ íæÊíæÈ
TY RTY
TRY
TRY TR
tyu ty
ytu ty
rt yer
rt yrt
人同意
bjklk
On jog of the mill, truthful estate price advance in 32 countries, included in rating, amounts 8,4% during a year. With an internet business you don’t need no span nevertheless for you have youre own product with the purpose of you distribute beside yourself. Finding a possessions to suit could prove grim if you are unaware of the urban’s geography after that what each piece can contain to suggestion your group. Singapore is not only rent office space easiest place on the road to do business in office rental properties planet (according to Doing Business 2009 Report) nevertheless it is besides the most competitive country in Asia (according to the World Economic Forum’s Global Competitiveness Report).
i think you are expericne in rss feed excellent
The post is excellent, the comments make it even more usefull. Did you know you are nice guys ? :-)
s code. Initially, that’s what got me excited about Open Source software. Otherwise, I was looking at small snippets on various developer sites and really not getting the comple
Wholesale Jeans,Wholesale Jeans
Nike Jordan 20,Nike Jordan 20
Nike Jordan 21,Nike Jordan 21
Jordan 17,Jordan 17
Jordan 18,Jordan 18
Jordan retro IV,Jordan retro IV
Jordan retro V,Jordan retro V
air jordans 4,air jordans 4
MBT Salama Sandals are hotsale in this hot summer and mbt shoes are spreaded around the world, especailly mbt shoes uk.
Now, I feel good, I started take up real income. vector conversion have never thought that there weren’t any need in big initial investment.Keep working, great job, I love it! digitizing software Thanks.Great post. I have been searching for this exact info for a while now. I will bookmark it in the public bookmarking sites to get you more traffic. stock designs Now lets see if I can do something productive with it.Otherwise, I was looking at small snippets on various developer sites and really not getting the comple
lation passed by the vintage cufflinks House last year and pending