我试图做一个python脚本,可以删除/撤消我最喜欢的所有我的twitter的最爱。我看过MATHEW INKSON's post来完成这项工作。我不需要删除我的推文,只想清除收藏夹。除此之外,该脚本已近两年之久,并且与最新的python不兼容。所以我编辑的一点与Python 3.6.0和我的脚本运行它看起来像这样:如何使用python删除所有的收藏夹?无法删除,获取错误。需要解决方案
import tweepy
from datetime import datetime, timedelta
test_mode = False
verbose = False
delete_favs = True
days_to_keep = 7
consumer_key = 'my consumer key'
consumer_secret = 'my consumer secret'
access_token = 'my access token'
access_token_secret = 'my access token secret'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
cutoff_date = datetime.utcnow() - timedelta(days=days_to_keep)
if delete_favs:
print ("Retrieving favorited tweets")
favorites = tweepy.Cursor(api.favorites).items()
unfav_count = 0
kept_count = 0
for tweet in favorites:
if tweet.created_at < cutoff_date:
if verbose:
print ("Unfavoring %d: [%s] %s % (tweet.created_at,tweet.text)")
if not test_mode:
api.destroy_favorite(tweet.id)
unfav_count += 1
else:
kept_count += 1
print ("Unfavored %d tweets, ignored %d" % (unfav_count, kept_count))
但是,通过每次在我的Windows命令运行该脚本,我得到这个以下错误:
Traceback (most recent call last):
File "C:\Users\xyz\Desktop\New folder\Unfavorite.py", line 25, in <module>
for tweet in favorites:
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy-3.6.0-py3.6.egg\tweepy\cursor.py", line 49, in __next__
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy-3.6.0-py3.6.egg\tweepy\cursor.py", line 197, in next
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy-3.6.0-py3.6.egg\tweepy\cursor.py", line 108, in next
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy-3.6.0-py3.6.egg\tweepy\binder.py", line 250, in _call
File "C:\Users\xyz\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy-3.6.0-py3.6.egg\tweepy\binder.py", line 234, in execute
tweepy.error.TweepError: Twitter error response: status code = 429
我使用Python 3.6,我的应用程序的权限都是正确的。一切都很好,我的twitter应用程序。我猜想我的脚本有问题。 请有人帮助修复我的代码。我也看过其他一些剧本。那些没有解决。建议将不胜感激。 感谢提前。
我投票结束这个问题作为题外话,因为垃圾邮件。 –
请不要破坏你的帖子。 –
@AlisterBulman只是破坏后,如果垃圾邮件,然后标记在它不会投票结束,任何方式,这不是垃圾邮件 –