Tôi muốn tìm kiếm hồ sơ của người theo dõi trên Twitter của người dùng bằng R (người theo dõi> 100000). Mặc dù twitteR là một gói tuyệt vời, nó có vấn đề khi đối phó với mức độ cao của những người theo như là một trong những nhu cầu để thực hiện một thói quen ngủ để tránh vượt quá giới hạn tốc độ. Tôi là một người mới tương đối ở đây và tự hỏi làm thế nào người ta có thể lặp qua đối tượng ID người theo dõi, nhập vào id người theo dõi theo lô 100 (vì đây là tối đa mà API Twitter có thể xử lý tại một thời điểm)?Tra cứu người theo dõi trên Twitter trong R
Chỉnh sửa: Mã thêm (Twitter) thư viện (plyr) maxTwitterIds = 100 sleeptime = 500 # giây
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)
})
Tôi nghĩ ở trang 6 của http://cran.r-project.org/web/packages/twitteR/twitteR.pdf bạn có thể tìm thấy thông tin tốt. – aatrujillob
Vâng, vấn đề là khi giao dịch với các danh sách lớn người theo dõi, bạn nhanh chóng vượt quá giới hạn tốc độ, vì vậy tôi đang tìm cách phá vỡ khối ID thành các lô 100 và chạy mỗi sau Sys.sleep. –