【发布时间】:2017-09-13 22:02:22
【问题描述】:
使用这是代码sn-p:
user = api.get_user('xxxx')
print(user.followers_count)
for i in user.friends():
print(i.screen_name)
追随者人数的结果是 700 但是为什么循环所有数据时只显示21行数据?
【问题讨论】:
使用这是代码sn-p:
user = api.get_user('xxxx')
print(user.followers_count)
for i in user.friends():
print(i.screen_name)
追随者人数的结果是 700 但是为什么循环所有数据时只显示21行数据?
【问题讨论】:
虽然获取用户所有关注者的姓名是可能的,但您可能会很快被禁止超过速率限制。
下面的代码会告诉你一个用户有多少粉丝,然后列出所有关注该用户的人的用户名。
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)
【讨论】: