Twython取消关注脚本

时间:2015-03-08 01:48:57

标签: python-2.7 twitter twython

我已经使用twython为python写了一个小脚本,随机取消了人们,但每当我运行代码时都没有任何反应。

mfriends = twitter.get_followers_ids(screen_name='myscreenname', count=50)

try:
    for unfollo in mfriends ['ids']:
        twitter.destroy_friendship(user_id=unfollo)
    except TwythonError as e:
        print(e)

1 个答案:

答案 0 :(得分:0)

您想修复try / except(语法无效):

from twython import Twython, TwythonError


app_key = 'your_key'
app_secret = 'your_secret'
oauth_key = 'your_oauth_key'
oauth_secret = 'your_oauth_secret'

twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)
mfriends = twitter.get_followers_ids(screen_name='myscreenname', count=50)

try:
    for unfollo in mfriends['ids']:
        twitter.destroy_friendship(user_id=unfollo)
except TwythonError as e:
    print(e)