Search code examples
pythontwittertweepy

Get tweets about certain items from a specific user


So I want to get historical tweets of a specific user talking about an item or containing this item I tried this code but it always gives me 0 tweets however I'm sure that the user had tweeted about this item

tweetCount = 0
item='trump'
with  open('historicalTweetsAboutItem.txt','w') as f:
    for status in tweepy.Cursor(api.user_timeline, screen_name='userScreenName', tweet_mode="extended").items():
        tweet=  status.full_text.encode('utf-8')        
        print(tweet)
        if item in tweet:
            f.write(tweet+ "\n")
            tweetCount += 1
print("Downloaded {0} tweets".format(tweetCount))
f.close()

Could someone gives me an easier way to get what I want plz :)


Solution

  • it is about majuscule and minuscule

    if item.upper() in tweet.upper():