Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering in tweepy

I am new to tweepy and have encountered a problem. I want to download tweets with special hashtags. But it seems

stream.filter(track = ['word1', 'word2', 'word3']) 

looks for these words in tweet and not in hashtags of the tweet. How can I filter on hashtags?

like image 613
Iryna Avatar asked Dec 25 '22 22:12

Iryna


1 Answers

You can actually filter tweets based on your special hashtag.

stream.filter(track=['#MySpecialHashtag', '#AlsoThisHashtag'])

This will pick up only tweets that contain the hashtags you provide as part of the tweet text and save you from arbitrarily collecting tweets and checking if the hashtag field has your hashtag in it.

like image 170
dbernard Avatar answered Jan 03 '23 04:01

dbernard