![](/img/trans.png)
[英]Determine if users are friends to one another from twitter user ids using rtweet/igraph
[英]Getting more than the number of friends allowed by Twitter API using rtweet
我編寫了以下腳本,該腳本以75,000的批次(每批5000個朋友)在批次中獲取Z2491BC9C7D8731EAE33124093BC7026Z用戶(“ rtweet
”)(在此示例中)。 但是,在腳本運行完成后,我發現朋友 ID 在固定間隔后重復。 例如,第 1、280001 和 560001 行具有相同的 ID。 第 2、280002 和 560002 行具有相同的 ID,依此類推。 我想知道我是否錯誤地理解了next_cursor
中的 next_cursor 。
u = "barackobama"
n_friends = lookup_users(u)$friends_count
curr_page = -1
fetched_friends = 0
i = 0
all_friends = NULL
while(fetched_friends < n_friends) {
if(rate_limit("get_friends")$remaining == 0) {
print(paste0("API limit reached. Reseting at ", rate_limit("get_friends")$reset_at))
Sys.sleep(as.numeric((rate_limit("get_friends")$reset + 0.1) * 60))
}
curr_friends = get_friends(u, n = 5000, retryonratelimit = TRUE, page = curr_page)
i = i + 1
all_friends = rbind(all_friends, curr_friends)
fetched_friends = nrow(all_friends)
print(paste0(i, ". ", fetched_friends, " out of ", n_friends, " fetched."))
curr_page = next_cursor(curr_friends)
}
任何幫助將不勝感激。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.