Reputation: 1
Whenever I run the code below, it gives me the most recent 10 tweets from @Spongebob
, instead of giving me the tweets that include "Bikini Bottom
" from the last 10 tweets. How do I make it conditional to the keyword?
user = api.get_user('SpongeBob')
public_tweets = api.user_timeline("Bikini Bottom", count=10, screen_name = "SpongeBob")
for tweet in public_tweets:
print(tweet.text)
Upvotes: 0
Views: 630
Reputation: 14334
You need to use the Twitter Search API, with the correct search operators.
In this case, you want to search for the string "bikini bottom from:spongebob
"
With Tweepy, this will be:
public_tweets = api.search("bikini bottom from:spongebob")
Upvotes: 1