I'm tracking all mentions of @UN with Tweepy using Twitter stream v1 API. However, I'm also getting all mentions of usernames containing @UN such as @UN_Women. I could filter them out in a post-processing step but this seems very inefficient.
Is there any way to avoid this?
This is my code:
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener())
myStream.filter(track=['@UN'])
Using
followinstead oftrackshould work. Withfollow, you supply a list of user IDs: