I am using backgroundrb to read rss feeds for all the sysmbols from Yahoo
finance.
require ''rss/2.0''
require ''open-uri''
class ResearchWorker < BackgrounDRb::Rails
def do_work(args)
yahoo_url = "http://finance.yahoo.com/rss/headline?s="
symbol_list = NasdaqSymbols.find_all()
while true
symbol_list.each do|sym|
temp_sym = sym.symbol.strip
temp_url = yahoo_url + temp_sym
@logger.debug("Searching for symbol: #{temp_url}")
get_feeds(temp_url,temp_sym)
end
sleep(10*60)
end # end of infinite loop
end # end of do_worker function
protected
def get_feeds(url,temp_sym)
open(url) do |http|
response = http.read
result = RSS::Parser.parse(response,false)
result.items.each_with_index do |item,i|
begin
title = item.title[0..99]
link = item.link
description = item.description
pub_date = item.pubDate
#check if the feed is there in db
feed_data = YahooFeeds.find(:first,:conditions => ["title
?",title])
unless feed_data.nil?
next
end
#@logger.debug("title = #{title} and link = #{link} ")
if feed = YahooFeeds.create(
:title => title,
:link => link,
:description => description,
:pub_date => pub_date,
:symbol => temp_sym
)
@logger.debug("Saved to #{temp_sym}")
else
@logger.debug("Error saving #{temp_sym}")
end
rescue Exception => e
@logger.debug("#{e.to_s}")
end
end
end
end # end of get_feeds function
end
On 8/7/06, Michael Siebert <info at siebert-wd.de>
wrote:>
> Great idea!
> unfortunately i don''t have any workers that anyone else would
need.
> IMO the list is completely enough. if there were forums, wikis and other
> stuff, there would be too much websites to check (at least for me)
>
> 2006/8/7, Ezra Zygmuntowicz <ezmobius at gmail.com>:
>
> > He folks-
> >
> > First off thanks to everyone for helping to make this plugin
> > work
> > better for all of us. Its nice to have a bunch of people testing and
> > adding features. I would like to ask for people to post some examples
> > workers. I would really like to get a few more workers to distribute
> > with the plugin. Especially ones that a lot of people seem to need
> > like Email workers. So if you are allowed to do so , would some
> > people please post some example workers and a few little instructions
> > on how to use them here on the list? Please use [EXAMPLE] in the
> > subject line.
> >
> > This will help out I think. We can tell people to search the
> > list
> > archives for [EXAMPLE] subject lines to get examples. Or do people
> > think I should put up a wiki and let people put their workers and
> > tutorials there? I would just like to have some real world examples
> > for folk just getting started with the plugin. And the workers I have
> > are very insurance company specific so I don''t think they are
> > examples that anyone else would gain much by looking at.
> >
> > What does everyone think? I want to spend more time working on
> > the
> > plugin so it would be great help if a few people would step up and
> > make some sample workers. Maybe even a little tutorial on how to make
> > an email queue worker would be cool.
> >
> >
> > Thanks Everyone-
> >
> > -Ezra
> > _______________________________________________
> > Backgroundrb-devel mailing list
> > Backgroundrb-devel at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/backgroundrb-devel
> >
>
>
>
> --
> Michael Siebert <info at siebert-wd.de>
>
> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
>
--
nothing much to talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20060808/41f808c3/attachment.html