Twython 取消关注脚本

Twython Unfollow Script

我已经使用 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)

您需要修复 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)