# Storing RSS feed in the Database

**URL:** <https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272>\
**Category:** Rails\
**Created:** [February 2, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272 "2007-02-02T20:49:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 2, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/1 "2007-02-02T20:49:17Z")

</div>

Hello all,

I have a requirement where I need to monitor a RSS feed.Once there  
is an update,I need t parse the title and content and store it in my  
DB table?  
Is this possible? Any ideas?  
Would appreciate any help.

Thanks  
Rails junkie

---

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 2, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/2 "2007-02-02T21:12:20Z")

</div>

On 2/2/07, Rails junkie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Rails junkie  
> You could use cron and ./script/runner and Hpricot to parse the feed  
> every-so-often and then simply save data to the DB as changes occur.

Hope this helps.

–  
Zack C.  
[http://depixelate.com](http://depixelate.com)

---

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 2, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/3 "2007-02-02T21:17:19Z")

</div>

Rails junkie wrote:

> Hello all,
> 
> I have a requirement where I need to monitor a RSS feed.Once there  
> is an update,I need t parse the title and content and store it in my  
> DB table?  
> Is this possible? Any ideas?  
> Would appreciate any help.
> 
> Thanks  
> Rails junkie

Look into FeedTools:

Site: [http://sporkmonger.com/projects/feedtools/](http://sporkmonger.com/projects/feedtools/)  
Tutorial: [http://sporkmonger.com/articles/2005/08/11/tutorial/](http://sporkmonger.com/articles/2005/08/11/tutorial/)

I’ve been meaning to get started on something like this but am finishing  
up another project. I’d love to know how you go about it.

Shai

---

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 2, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/4 "2007-02-02T21:32:21Z")

</div>

Thank you All  
This really helps and enough to get me started.

---

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 2, 2007, 9:29pm UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/5 "2007-02-02T21:29:21Z")

</div>

This is how I do it in one of my project that has similar  
requirements.  
You have two problems  
First is to get and parse the rss - trivial

require ‘rss’

path = “[B92 biz](http://www.b92.net/info/rss/biz.xml)”

rssB92biz = RSS::Parser.parse(path)  
rssB92biz.items.each do|item|  
puts “====================================================”  
puts item.title  
puts item.link  
puts item.description  
puts “====================================================”  
end

Second is to determine the uniqueness of rss item. I will use the link  
but it’s up to you 🙂  
The next is to store the new unique rss item in db witch is like any  
other model manipulation.

The interesting part is to make this a background task of your  
application.  
For that task I have used BackgrounDRb (http://  
[backgroundrb.rubyforge.org](http://backgroundrb.rubyforge.org)).  
I hope that I put you on a right course.  
If you need some more details just ask.

Dejan

On Feb 2, 8:48 pm, “Rails junkie” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Rails\_junkie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@Rails\_junkie](https://www.ruby-forum.com/u/Rails_junkie)\
**Post date:** [February 6, 2007, 7:03am UTC](https://www.ruby-forum.com/t/storing-rss-feed-in-the-database/84272/6 "2007-02-06T07:03:59Z")

</div>

As you suggested, everything worked.  
Thank you.  
I have one question though.  
How Do in limit the RSS feed retrieval to only new ones?  
If I parse a url, and run a loop, it has all the feeds on that url. is  
there way to restrcit to only updated ones?

Thanks
