rubyweb-scrapingtwittertimelinetweets

Using Ruby and Twitter can I gather ALL of a user's timeline?


I'm trying to retrieve a user's timeline. The api says you can get (at the most) 3,200 tweets. I only seem to know how to get 20 using this code:

def gather_tweets_from(user)
  tweets = []
  file = File.open("tweets_from.txt","w")
  client.user_timeline(user).each { |tweet| 
    file.puts tweet.text
  }
end
gather_tweets_from(user)

Please help me out, Thanks :)


Solution

  • The user_timeline function lets you specify certain options. What you're looking for is something like

    client.user_timeline(user, :count => 200).each { |tweet| 
      file.puts tweet.text
    

    http://www.rubydoc.info/gems/twitter/Twitter/REST/Timelines:user_timeline