Python Forum
Check if tweet is favorited by myself | TWEEPY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if tweet is favorited by myself | TWEEPY
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  split and test tweet data Jmekubo 1 2,161 May-08-2019, 10:48 AM
Last Post: michalmonday
  tweepy problem to to get a list of retweeters komarek 1 6,577 Jun-05-2018, 04:20 PM
Last Post: aguro90
  tweepy:invalid or expired token weareux 2 6,470 Dec-03-2017, 07:27 PM
Last Post: micseydel
  Collecting Data from Twitter with Tweepy and MongoDB fatony 1 3,926 Apr-10-2017, 09:38 PM
Last Post: fatony

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020