我尝试使用 twitteR 函数“searchTwitter”检索带有关键字“nba”或主题标签“#nba”的约 3000 条推文,但在 2013 年 1 月期间仅返回“nba”的 299 条推文和“#nba”的 398 条推文-01 和 2014-02-25。我真的很困惑,这正常吗?有其他人在使用 twitter 时遇到过类似的问题吗?请帮忙。非常感谢!
library(twitteR)
library(plyr)
library(stringr)
load("~/twitter_authentication.Rdata")
registerTwitterOAuth(cred)
nbahash_tweets = searchTwitter("#nba",since='2013-01-01', until='2014-02-25',n=3000)
nba_tweets = searchTwitter("nba",since='2013-01-01', until='2014-02-25',n=3000)
Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
3000 tweets were requested but the API can only return 398
然后
Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit, :
3000 tweets were requested but the API can only return 299
最佳答案
这是由于 Twitter 搜索 API 的限制。在 Twitter 的 FAQ 中我发现了以下问题: Why are the Tweets I'm looking for not in Twitter Search, the Search API, or Search widgets?
上面写着:
Due to capacity constraints, the index currently only covers about a week's worth of tweets.
因此,即使您想下载 2013 年 1 月 1 日开始的推文,您最多也只能获得一周前的推文。所以推文的数量不会那么大。
此外,他们说:
Our search service is not meant to be an exhaustive archive of public tweets and not all tweets are indexed or returned.
因此,可用的推文将会更少。
因此,据我所知,您的代码应该没问题,下载的推文数量较少是由搜索 API 造成的。
关于r - TwitteR: 'searchTwitter' 仅返回一小部分推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22052811/