Hi, I am trying to find the followers of a twitter
account using python
.
What I did was this, but it looks for the users that I follow. And I only print one. I need you to print all FOLLOWERS of the account.
Does anybody give me a hand?
import tweepy
consumer_key='WjH7YmuRQP0Aq0u20YWQqXIpG'
consumer_secret='yg7oaMjGPwyu47ilP8GVhTkWxm3NJPhYJnRnIbxKqkHRNorE81'
access_token='922967657988673536-aT8byXalXV86aBiLs7ATW5CZGAjAboX'
access_token_secret='KeyYPINllDbT5sVtlfvA1Z2liyS34PbcFm5c1FrNxAkTm'
auth=tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api= tweepy.API(auth)
def seguidores(api):
try:
usuario=str(input("ingrese su nombre de usuario colocando el arroba @: "))
if usuario[0]=="@":
user=api.get_user(usuario)
for friend in user.friends() :
print(friend.screen_name.encode('utf-8'))
return()
else:
usuario="@"+usuario
user=api.get_user(usuario)
for friend in user.friends():
print(friend.screen_name.encode('utf-8'))
return()
except tweepy.TweepError as err:
print("Error: ", err)
return -1
seguidores(api)