1

我正在使用 Pablo Barbera 代码的修改版本 ( https://github.com/pablobarbera/workshop/blob/master/code/02_analysis_twitter_nyu.R ) 来绘制个人及其关注者的 Twitter 关注者网络。朋友/身份证的速率限制为 15 次通话/15 分钟。但是,我的代码不断超出此范围。

对于如何解决速率限制问题的任何提示,我将不胜感激。我怀疑问题出在 while 循环内(复制如下)

while (length(ir_pol.users) > length(follow.list)) {
   user <- ir_pol.users[ir_pol.users %in% names(follow.list) == FALSE], 1)
   user <- getUser(user)
   user.n <- user$screenName
   following <- user$getFriends()
   friends <- as.character(lapply(following, function(x) x$getScreenName()))
   follow.list[[user.n]] <- friends
   descriptions <- as.character(lapply(following, function(x) x$getDescription()))
   ir_pol <- extract.irishpolitics(descriptions)
   new.users <- lapply(following[ir_pol], function(x) x$getScreenName())
   new.users <- as.character(new.users)
   ir_pol.users <- unique(c(ir_pol.users, new.users))
   limit <- getCurRateLimitInfo()[47, 3]
   while (limit == "0") {
      Sys.sleep(901)
      limit <- getCurRateLimitInfo()[47, 3]
      }

   print(ir_pol.users)
}
4

0 回答 0