Tweepy - TweepError 代码 89:无效或过期的令牌
Tweepy - TweepError Code 89: Invalid or expired token
我正在尝试取消关注使用 tweepy. It worked just fine when I used it earlier. But, then it started to get the Code 89: Invalid or expired token
error. I visited 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)))
将睡眠时间从 60
增加到 100
成功了。显然,修改后的脚本需要更多的时间来执行。但是,它有效...
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(100)
except Exception as e:
print(e)
time.sleep(120)
continue
print("Now, Following, %d(%d)" % (api.me().friends_count, len(friendlist)))
我正在尝试取消关注使用 tweepy. It worked just fine when I used it earlier. But, then it started to get the Code 89: Invalid or expired token
error. I visited 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)))
将睡眠时间从 60
增加到 100
成功了。显然,修改后的脚本需要更多的时间来执行。但是,它有效...
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(100)
except Exception as e:
print(e)
time.sleep(120)
continue
print("Now, Following, %d(%d)" % (api.me().friends_count, len(friendlist)))