Twitter API - Get number of followers of followers

筅森魡賤 提交于 2019-12-05 11:31:29

You don't need to get all user followers in order to count them. Use followers_count property. E.g.:

import tweepy

auth = tweepy.OAuthHandler(..., ...)
auth.set_access_token(..., ...)

api = tweepy.API(auth)

for user in tweepy.Cursor(api.followers, screen_name="twitter").items():
    print user.screen_name, user.followers_count

Prints:

...
pizzerialoso 0
Mario98Y 0
sumankumarjana 1
realattorneylaw 3056
JaluSeptyan 10
andhita_khanza 18
...

Hope that helps.

This works. However, I have an alternate solution which can get specific user based quantitative info such as count of followers, statuses etc.

import tweepy
auth = tweepy.OAuthHandler(..., ...)
auth.set_access_token(..., ...)
api = tweepy.API(auth)

follower_count = api.get_user('twitter').followers_count
print(follower_count)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!