Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.80 KB | None | 0 0
  1. require "twitter"
  2.  
  3. client = Twitter::REST::Client.new do |config|
  4.         config.consumer_key = 'vvDpEO4YjkWQxFANOC860iDdZ'
  5.         config.consumer_secret = 'iJBruzon2FeM7IllT38y1r2yjm0sLbXXjoAOlD8W9HgDxYoQe5'
  6.         config.access_token = '1519115875-MDKhYr6SQ5BKi4ZcyFnIqZPn7AL0a7OfC2q8rsw'
  7.         config.access_token_secret = 'Rvu3pyrwvuhnTu25642th0HVZGubzNhHTzRDCljKzwNMs'
  8. end
  9.  
  10. #set max_id to max value
  11. mnid = 999999999999999999
  12. #set number of tweets you want to get
  13. max_no_tweets = 3500
  14. count = 0
  15. while(count < max_no_tweets)
  16.     #each loop gets 200 tweet
  17.     client.user_timeline('elonmusk', :count => 200, :max_id => mnid).each do |tweet|
  18.         puts(tweet.text) if tweet.is_a?(Twitter::Tweet)
  19.         #to get the next 200 tweet
  20.         mnid = [mnid,tweet.id].min
  21.         count+=1
  22.     end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement