I am trying to write all tweets that matches a keyword to my database. I have set up the following in tracker.rb
:
require 'rubygems'
require 'tweetstream'
TweetStream::Daemon.new('Bill Gates','money','Twitter Tracker').track('ladygaga') do |status|
Tweet.new(:content => status.text)
end
But nothing happens. What am I doing wrong here?
Thanks in advance
Update:
I put everything in a .rake
file called twitter.rake
and start the demon with $ rake scrap
:
task :scrap => :environment do
desc "Run Twitter Scraper"
TweetStream::Client.new('TWITTER_USER','TWITTER_PASS').track('ladygaga') do |status|
Tweet.create(:user_id => status.user.id, :user_screen_name => status.user.screen_name, :user_profile_image_url => status.user.profile_image_url, :status_text => status.text, :status_id => status.id)
puts "[#{status.user.screen_name}] #{status.text}"
end
end