Python / Tweepy: skip tweet that has already been liked

Viewed 23

I'm currently trying to create a simple like bot for twitter and I have the problem that I keep getting "403 Forbidden 139 - You have already favorited this status."

I've added an if query so that it skips tweets that have already been liked, but I keep getting the 139 error - what am I doing wrong?

search = "python" 
nrTweets = 20

for tweet in tweepy.Cursor(api.search_tweets, search).items(nrTweets):
    try:
        if not tweet.favorited:
            tweet.favorite()
            print('Tweet Liked')
            time.sleep(60)
        else:
            continue
    except tweepy.TweepyException as e:
        print(e)

Example result:

Tweet Liked
Tweet Liked
Tweet Liked
Tweet Liked
403 Forbidden
139 - You have already favorited this status.
0 Answers
Related