Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. b = Benchmark.realtime do
  2. begin
  3. (1..10).each do |page|
  4. Twitter.user_timeline(username, :page => page, :count => 50).each do |tweet|
  5. if saved_tweets.include?(tweet.id.to_s)
  6. already_saved += 1
  7. else
  8. time = date_time(tweet.created_at).to_time.to_s
  9. db.execute("INSERT INTO #{@tableid} (protocol, username, pdate, content, content_id, location) VALUES(?,?,?,?,?,?)", protocol, username, time, tweet.text, tweet.id, location)
  10. printf('*')
  11. count_tweets += 1
  12. end
  13. end
  14. end
  15. rescue
  16. retries += 1
  17. if retries > 3
  18. puts "\nThere was a connection problem. This usually happens when this account has high traffic. Please try later."
  19. else
  20. puts "\nFailed #{retries} time(s) to fetch data... Retrying...\n"
  21. retry
  22. end
  23. end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement