![]() |
Check if tweet is favorited by myself | TWEEPY - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Check if tweet is favorited by myself | TWEEPY (/thread-29707.html) |
Check if tweet is favorited by myself | TWEEPY - altayko - Sep-16-2020 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? 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 |