Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- b = Benchmark.realtime do
- begin
- (1..10).each do |page|
- Twitter.user_timeline(username, :page => page, :count => 50).each do |tweet|
- if saved_tweets.include?(tweet.id.to_s)
- already_saved += 1
- else
- time = date_time(tweet.created_at).to_time.to_s
- db.execute("INSERT INTO #{@tableid} (protocol, username, pdate, content, content_id, location) VALUES(?,?,?,?,?,?)", protocol, username, time, tweet.text, tweet.id, location)
- printf('*')
- count_tweets += 1
- end
- end
- end
- rescue
- retries += 1
- if retries > 3
- puts "\nThere was a connection problem. This usually happens when this account has high traffic. Please try later."
- else
- puts "\nFailed #{retries} time(s) to fetch data... Retrying...\n"
- retry
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement