Skip to content

Instantly share code, notes, and snippets.

@gwuah
Created November 11, 2017 14:45
Show Gist options
  • Save gwuah/acabb5c59b2b883dd082c54feb174678 to your computer and use it in GitHub Desktop.
Save gwuah/acabb5c59b2b883dd082c54feb174678 to your computer and use it in GitHub Desktop.
sample python snippet to retrieve all followers of a user using the tweepy wrapper
import tweepy
API_KEY = ''
API_TOKEN = ''
ACCESS_TOKEN = ''
ACCESS_TOKEN_SECRET = ''
def authenticate():
auth = tweepy.OAuthHandler(API_KEY, API_TOKEN)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
return tweepy.API(auth)
api = authenticate()
followers = []
user = api.get_user("gwuah_")
for user in user.followers():
followers.append(user.screen_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment