How to get twitter followers using Twython?

I want to get a list of twitter followers / following a specific user when their screen name or user.id is indicated. Can someone please give a code snippet for this? Thank.

+5
source share
3 answers

I am the author of Twython. Two different methods can be used for this; one that returns only identifiers get_followers_ids( get_followers_ids), and one that returns the status / etc of set get_followers_list( get_followers_list).

A sample code for one will look like this:

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

, , (get_followers_list) , . , Twython API API Twitter, , , , .

!

+19
from twython import Twython

twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

followers = twitter.get_followers_ids(id = 1234) # or just () - followers for your account

print(twitter.get_followers_ids()['ids']) # ids list of followers
+2

It should be:

followers = twitter.get_followers_list(screen_name = "whatever")
+1
source

All Articles