Python tweetbot跟随代码将无法正常工作

时间:2016-06-12 20:14:32

标签: python

我正在构建一个tweetbot,并且在运行我的代码时一直出现错误,这只是在我尝试添加代码后跟随我的任何人(我再次运行之前从文本文件中删除推文,错误到期)时出现的错误跟随人们回来的部分):

import tweepy, time

CONSUMER_KEY = 'KEY'
CONSUMER_SECRET = 'KEY'
ACCESS_KEY = 'Key'
ACCESS_SECRET = 'Key'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

for follower in tweepy.Cursor(api.followers).items():
    follower.follow()

filename=open('file.txt','r')
tweets=filename.readlines()
filename.close()

for line in tweets:
    api.update_status(line)
    print line, time.strftime("%H:%M:%S")
    time.sleep(120)

这是错误

File "tweetbot.py", line 19, in <module>
api.update_status(line)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-    packages/tweepy/api.py", line 194, in update_status
)(post_data=post_data, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/binder.py", line 245, in _call
return method.execute()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/binder.py", line 229, in execute
raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: [{u'message': u'Status is a duplicate.', u'code': 187}]

1 个答案:

答案 0 :(得分:2)

如果你有相同的推文,Tweepy不会让你发推文......

所以你可以这样做 -

for status in tweepy.Cursor(api.user_timeline).items():
        api.destroy_status(status.id)