
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@R_404_6120@ Twitter API docs状态
rppThe number of tweets to return per page,up to a max of 100.http://search.twitter.com/search.Json?rpp=100pageThe 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
因此看起来1500是内置限制.
总结以上是内存溢出为你收集整理的如何使用ruby twitter gem获取大量推文全部内容,希望文章能够帮你解决如何使用ruby twitter gem获取大量推文所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)