首页 > 解决方案 > 在 for 循环中 TwitteR searchTwitter() 调用不起作用

问题描述

我目前正在尝试对 NBA 中的 21 名球员中的每一位进行 searchTwitter() 调用,以获取有关他们的 100 条最新推文。然而,奇怪的是,该调用在我的 lastMVPs 循环(这是一个名称列表)中工作,但在 10 次循环后停止,这将只有 1,000 个 API 调用。现在该调用仅在 for 循环之外有效。有谁知道这是为什么?

例如 - 这有效:

searchTwitter("Lebron James", n = 2, lang = 'en')

但这不会:

for (name in lastMVPs) {
  newitem = searchTwitter(name, n = 100, lang = 'en')
  df = twListToDF(newitem)
  name = df$text
  tweetMatrix = cbind(tweetMatrix, name)
}

我得到了错误

Error in twListToDF(newitem) : Empty list passed to twListToDF
In addition: Warning message:
In doRppAPICall("search/tweets", n, params = params, retryOnRateLimit = retryOnRateLimit,  :
  100 tweets were requested but the API can only return 0

这对我来说没有意义,因为当 API 已经在循环外为我的调用工作时,它如何才能最大化?

标签: rtwitter

解决方案


推荐阅读