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
How are you calling the Daemon?
You need to supply a command (start/stop..)
For example:
rails runner "TweetStream::Daemon.new('tracker').track('ladygaga') { |status| do_something }" start
This would start the job in the background
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With