【问题标题】:TweePy For Loop not looping all dataTweePy For Loop 不循环所有数据
【发布时间】: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行数据?

【问题讨论】:

    标签: python for-loop tweepy


    【解决方案1】:

    虽然获取用户所有关注者的姓名是可能的,但您可能会很快被禁止超过速率限制。

    下面的代码会告诉你一个用户有多少粉丝,然后列出所有关注该用户的人的用户名。

    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)
    

    【讨论】:

      猜你喜欢
      • 2017-11-30
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      • 2018-07-08
      • 1970-01-01
      • 2021-10-17
      • 2021-09-17
      相关资源
      最近更新 更多