Search code examples
pythonpython-3.xtwittertwitter-oauthtweepy

Retweets of my tweets


So I am trying to find out retweets of my tweets using tweepy

# To get first tweet
firstTweet = api.user_timeline("zzaibis")[0]

# then getting the retweet data using tweet id and it gives me the results 
resultsOfFirstTweet = api.retweets(firstTweet.id)

# but when I try to find any other tweet except first tweet, this returns nothing.
secondTweet = api.user_timeline("zzaibis")[1]

Any idea why this is not working beyond that, and also what I need to follow to get all the retweet data of my tweets considering that I don't have limited tweets and retweets in my account.


Solution

  • To find the number of retweets a user gets on each tweet from their timeline try the following code:

    for tweet in api.user_timeline(screen_name = 'StackOverflow', count = 10):
        print(tweet.retweet_count)
    

    To edit the user who is being searched change the "screen_name" to the username of the person you want to search. To change the number of statuses is seaches change the "count".

    you can also print information like the tweet id of the tweet being searched using:

    print(tweet.id)