r - 在 R 中查找 Twitter 关注者

标签 r twitter

我想使用 R 查找用户的 Twitter 关注者的个人资料(关注者 > 100000)。尽管 twitteR 是一个很棒的软件包,但它在处理大量关注者时存在问题,因为人们需要实现 sleep 程序以避免超过速率限制。我是这里的相对新手,想知道如何遍历关注者 ID 对象,以 100 个为一组输入关注者 ID(因为这是 Twitter API 一次可以处理的最大值)?

编辑:添加了代码
(推特)
图书馆(plyr)
maxTwitterIds = 100
sleep 时间 = 500 # 秒

user<-getUser("[username]")
followers<-zz$getFollowerIDs()
ids_matrix = matrix(zz, nrow = maxTwitterIds, ncol = length(zz) / maxTwitterIds)
followers<-zz$getFollowerIDs()
#note: for smaller lists of followers it is possible to use the command "lookupUsers(zz)     at this point
foll<-getTwitterInfoForListIds = function(id_list) {
    return(lapply(id_list, 

names <- sapply(foll,name)
sn<sapply(foll,screenName)
id<-sapply(foll,id)
verified<-sapply(foll,erified)
created<-sapply(foll,created)
statuses<-sapply(foll,statusesCount)
follower<-sapply(foll,followersCount)
friends<-sapply(foll,friendsCount)
favorites<-sapply(foll,favoritesCount)
location<-sapply(foll,location)
url<-sapply(foll,url)
description<-sapply(foll,description)
last_status<-sapply(foll,lastStatus)))
}
alldata = alply(, 2, function(id_set) {
    info = getTwitterInfoForListIds(id_set)
    Sys.sleep(sleeptime)   
    return(info)
})

最佳答案

这也可以使用较新的 rtweet 来完成。包裹。

根据此处的示例:https://github.com/mkearney/rtweet

# Get followers 

# Retrieve a list of the accounts following a user.

## get user IDs of accounts following CNN 
cnn_flw <- get_followers("cnn", n = 75000)

# lookup data on those accounts 
cnn_flw_data <- lookup_users(cnn_flw$user_id) 

# Or if you really want ALL of their followers:
# how many total follows does cnn have? 
cnn <- lookup_users("cnn")
# get them all (this would take a little over 5 days) 
cnn_flw <- get_followers(   "cnn", n = cnn$followers_count, 
  retryonratelimit = TRUE )

关于r - 在 R 中查找 Twitter 关注者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9192698/

相关文章:

r - ade4软件包-主成分分析

在 Sweave 中渲染网格图形

r - R all.equal 中可能存在的错误

android - 应用内 Twitter 时间线无需身份验证?

ios - 检查 Parse 用户是否已经链接到 facebook 或 twitter

r - 创建 input$selection 来子集数据和单选按钮以在 Shiny 中选择绘图类型

R data.table lapply 带剪切功能

R - Twitter - fromJSON - 获取推文列表

twitter - 特定推文的 Twitter 链接的 URL

python - 检查 Twitter 友谊的最有效方法? (超过5000支票)