Created
September 12, 2016 18:20
-
-
Save saurabhwahile/743b8a8236170d5102dd27ab0fb87fa5 to your computer and use it in GitHub Desktop.
Mass unfollow on twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tweepy | |
auth = tweepy.auth.OAuthHandler( | |
consumer_key="key", | |
consumer_secret="secret") | |
auth.set_access_token( | |
'token', | |
'secret') | |
api=tweepy.API(auth_handler=auth) | |
unfollow_list = [ | |
#list of csv user-ids | |
] | |
for u in unfollow_list: | |
print u | |
try: | |
u = api.get_user(u) | |
except tweepy.error.TweepError, e: | |
if e.api_code == 50: | |
continue | |
else: | |
print e.message | |
break | |
print u.screen_name | |
print u.unfollow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment