Reputation: 79
I am currently using Tweepy to access the Twitter API for some sentiment analysis. However, when I run the following code:
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit = True)
public_tweets = api.search('Donald Trump')
I only get 14 tweets? Is There any way to retrieve more/specify that you want more?? Any help would be much appreciated!!
Upvotes: 0
Views: 93
Reputation: 128
Try using this:
auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth, wait_on_rate_limit = True)
your_query = "your query"
public_tweets = api.search(your_query, count=100)
This is the maximum number of tweets you can get in one request. By default the count is set to 15. Moreover by default it shows the most recent 100 tweets which include your query.
If you need more than 100 Tweets you need either save the minimum id and set is as max_id attribute or use tweepy.cursor. If you search you will find its tutorial on tweepy doc.
Upvotes: 1