How to get a lot of tweets using ruby ​​twitter

I wrote a few ruby ​​to return all tweets containing the phrase within the time range. However, this code will return a maximum of 1,500 tweets. How can I get more than 1,500 tweets? (I hope to get hundreds of thousands of tweets)

require "rubygems" require "twitter" # returns a list of tweets containing the phrase within the dates specified # returns either @max_tweets tweets or all tweets found # @param phrase - a phrase to search for # @param from_date - begining date of the search ex."2011-02-28" # @param until_date - ending date of the search ex. "2011-03-01" def get_tweets(phrase, from_date, until_date) search = Twitter::Search.new.containing(phrase).since_date(from_date).until_date(until_date) #get all the tweets tweets = search.fetch next_tweets = search.fetch_next_page while(tweets.size < @max_tweets && next_tweets != nil) tweets = tweets + next_tweets next_tweets = search.fetch_next_page end return tweets.first(@max_tweets) end 
+4
source share
1 answer

Twitter API docs state

 rpp The number of tweets to return per page, up to a max of 100. http://search.twitter.com/search.json?rpp=100 page The page number (starting at 1) to return, up to a max of roughly 1500 results (based on rpp * page). http://search.twitter.com/search.json?page=10 

So it looks like 1500 is the built-in limit.

+4
source

Source: https://habr.com/ru/post/1343053/


All Articles