簡體   English   中英

使用 rtweet 獲得超過 Twitter API 允許的朋友數量

[英]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)
}

任何幫助將不勝感激。

你沒有做錯任何事。 文檔中

此訂單可能會出現未宣布的更改和最終的一致性問題

對於非常大的列表,API 根本不會返回您想要的所有信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM