How to get twitter followers using Twython?

泪湿孤枕 提交于 2019-12-04 12:47:14

问题


I want to get a list of twitter followers/following of a particular user, when their screenname or user.id is specified. Can anyone please give the code snippet for it? Thanks.


回答1:


I'm the author of Twython. There's two different methods you can use for this; one that returns just follower IDs (get_followers_ids), and one that returns the statuses/etc of a follower set (get_followers_list).

Some example code for one would be like the following:

from twython import Twython

twitter = Twython()
followers = twitter.get_followers_ids(screen_name = "ryanmcgrath")

for follower_id in followers:
    print "User with ID %d is following ryanmcgrath" % follower_id

If you have IDs, you'd need to do further lookups yourself, so the latter method (get_followers_list) may be what you want. Keep in mind that Twython functions just mirror API key parameters from the official Twitter API docs, so the methods you can pass to an argument are the same as what you'll find on the docs.

Good luck!




回答2:


It should be :

followers = twitter.get_followers_list(screen_name = "whatever")


来源:https://stackoverflow.com/questions/5963792/how-to-get-twitter-followers-using-twython

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