我尝试编写的代码需要一份关注我的所有帐户的列表,但我编写的代码仅准确地获得了 313 个帐户中的 193 个:
followers = api.user_followers(api.authenticated_user_id, rank_token = Client.generate_uuid())
myFollowers = []
for i in range(len(followers['users'])):
myFollowers.append(followers['users'][i]['username'])
print(myFollowers)
我可以改变什么才能获得所有关注者?
您可以使用“max_id”参数获取所有用户。 请检查下面的代码。
myFollowers = []
next_max_id = "0"
while next_max_id != None :
followers = api.user_followers(api.authenticated_user_id, rank_token = Client.generate_uuid(), max_id=next_max_id)
next_max_id = followers.get('next_max_id')
for i in range(len(followers['users'])):
myFollowers.append(followers['users'][i]['username'])
print(myFollowers)