Having trouble with follow in Stream.filter

570 views
Skip to first unread message

rubin...@gmail.com

unread,
Mar 16, 2012, 5:33:27 PM3/16/12
to twe...@googlegroups.com
I'm trying to limit by stream to a specific user or set of users. I'm entering the user IDs  like so:

streamer = tweepy.streaming.Stream(auth, Listener(), timeout=60)                                                                                                              
streamer.filter(follow=[523460971,23595586], track=["traffic"])

But my stream shows all tweets with "traffic", regardless of the user. 

Here's my full code:

class Listener(tweepy.StreamListener):                                                                                                                                            
                                                                                                                                                                                  
    def on_status(self, status):                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                       
        try:                                                                                                                                                                                                                                                                             
            print "%s\t%s\t%s\t%s" % (status.text,                                                                                                               
                                                       status.author.screen_name,                                                                                                 
                                                       status.created_at,                                                                                                         
                                                       status.source,)                                                                                                            
                                                                                                                                                                                  
        except Exception, e:                                                                                                                                                      
            print >> sys.stderr, 'Encountered Exception:', e                                                                                                                      
            pass                                                                                                                                                                  
                                                                                                                                                                                  
    def on_error(self, status_code):                                                                                                                                              
        print >> sys.stderr, 'Encountered error with status code:', status_code                                                                                                   
        return True # Don't kill the stream                                                                                                                                       
                                                                                                                                                                                  
    def on_timeout(self):                                                                                                                                                         
        print >> sys.stderr, 'Timeout...'

try:                                                                                                                                                                              
    streamer = tweepy.streaming.Stream(auth, Listener(), timeout=60)                                                                                                              
    streamer.filter(follow=[523460971,23595586], track=["traffic"])                                                                                                           
                                                                                                                                                                                  
except KeyboardInterrupt:                                                                                                                                                         
    print "\nGoodbye..."                                                                                                                                                          
    exit 

Any help would be greatly appreciated. 

Thanks!

Aaron

rubin...@gmail.com

unread,
Mar 16, 2012, 9:41:04 PM3/16/12
to twe...@googlegroups.com
Experimenting a little more, it looks like if I only specify a list for the follow argument and leave track as the default None, I can limit my stream to the users specified. So it looks like I can't use track and follow together. 

I can write custom code to filter the statuses of those users so I can work around the problem but this seems like it might be a bug.

Aaron

unbu...@gmail.com

unread,
Mar 18, 2014, 3:55:56 AM3/18/14
to twe...@googlegroups.com, rubin...@gmail.com
Did you fix it? I'm having the very same problem.
Reply all
Reply to author
Forward
0 new messages