使用此代码段:
user = api.get_user('xxxx')
print(user.followers_count)
for i in user.friends():
print(i.screen_name)
跟随者计数的结果是700 但为什么在循环所有数据时只显示21行数据?
答案 0 :(得分:0)
虽然可以获得用户所有关注者的姓名,但很可能会被禁止超出速率限制。
以下代码会告诉您用户拥有多少粉丝,然后列出关注该用户的所有用户名。
username = 'keely_bro'
userID = api.get_user(username)
print('User is followed by ' + str(userID.followers_count) + ' people')
print('usernames of followers: ')
for allFollowers in tweepy.Cursor(api.followers_ids, screen_name=username).pages():
followerNames = [userID.screen_name for userID in api.lookup_users(allFollowers)]
for follow in followerNames:
print(follow)