Sep-16-2020, 05:40 PM
On Tweepy, I get too many "You have already favorite this tweet" error and when it gives this error repeatedly, the API rate limit error[code 429] is issued.
Before attempting to favorite the tweet to resolve this issue, before favorite the tweet I want to check if the tweet is not favourited by me. But I haven't been able to enter the while / else command in my code, I would appreciate if anyone could help.
I tried the code below and added the part "favorited = status.favorited" where am I doing wrong?
Before attempting to favorite the tweet to resolve this issue, before favorite the tweet I want to check if the tweet is not favourited by me. But I haven't been able to enter the while / else command in my code, I would appreciate if anyone could help.
I tried the code below and added the part "favorited = status.favorited" where am I doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import tweepy import time auth = tweepy.OAuthHandler( 'secret_credentials' , 'secret_credentials' ) auth.set_access_token( 'access_token' , 'access_token' ) api = tweepy.API(auth, wait_on_rate_limit = True , wait_on_rate_limit_notify = True ) user = api.me() for tweet in tweepy.Cursor(api.search, q = "books" , result_type = "recent" ).items( 70 ): status = api.get_status(tweet) favorited = status.favorited if favorited = = False : try : print ( 'Tweet Liked' ) tweet.favorite() time.sleep( 10 ) except tweepy.TweepError as e: print (e.reason) except StopIteration: break |