0

Hi I am trying to get the tweets that has an unique keyword and posted from a specific user with tweepy.

I wrote the code below but I can't get all tweets. How can I fix this issue?


def get_tweet_keyword_from_user(keyword, user):
    tweets = tw.Cursor(api.search_tweets, q=keyword + " from:" + user, tweet_mode='extended', count=100).items()
    for tweet in tweets:
        print(tweet.full_text)


    return
fy23
  • 1

1 Answers1

0

you should remove the "count" field from your code, as it's instructing your code to stop after it found 100 tweets.

The maximum limit set by the Twitter API, is typically around 3200 tweets.

In Tweepy, you can use the wait_on_rate_limit parameter when initializing the API object to automatically wait for rate limits to reset:

# Create Tweepy API object with higher rate limits
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)

# Now you can make API requests with the elevated rate limits
GoldLocke
  • 9
  • 3