Find a certain word in a given user Tweepy

0

Following the documentation, I was able to create a code that extracts tweets by TAg, and another that extracts tweets from some user. But I'm having trouble extracting tweets from someone by tag.

resultado = [[tweet.id_str, tweet.created_at,tweet.coordinates,tweet.geo,tweet.truncated,tweet.text] for tweet in alltweets if tweet.text == 'palavra_chave']

The code only downloads tweets that contain only the keyword. For example, the keyword is 'Today'. If the tweet is 'Today was good', it does not identify.

    
asked by anonymous 20.06.2018 / 00:29

1 answer

0

This is why you require, in your list understanding, that the text be exactly the same as the keyword:

... for tweet in alltweets if tweet.text == 'palavra_chave']

If you want to check that the keyword is inside the tweet, you should use the in :

... for tweet in alltweets if 'palavra_chave' in tweet.text]
    
20.06.2018 / 02:10