【发布时间】:2018-02-14 04:08:52
【问题描述】:
我正在尝试取消关注使用 tweepy 的人。当我早些时候使用它时,它工作得很好。但是,随后它开始出现Code 89: Invalid or expired token 错误。我访问了https://apps.twitter.com/ 页面。而且,发现我的帐户访问令牌被撤销了。但是,我再次生成了 access token 并再次尝试了一次。它取消关注另一个人,又取消关注Error Code: 89。
再次尝试,设置了 60 秒的睡眠时间,同样的事情发生了。
它取消关注一个人,然后再取消关注Error Code: 89,并且访问令牌再次自动撤销。
name = api.me().name
friendlist = api.friends_ids(name)
followers = api.followers_ids(name)
with open('unfollowed.csv', "w") as f:
for suspect in friendlist:
if suspect not in followers and suspect not in protected_friends:
try:
txt = str(suspect)+", " +"https://twitter.com/%s" % api.get_user(suspect).screen_name
print(txt)
f.write(txt+'\n')
api.destroy_friendship(suspect)
time.sleep(60)
except Exception as e:
print(e)
time.sleep(60)
continue
print("Now, Following, %d(%d)" % (api.me().friends_count, len(friendlist)))
【问题讨论】: