Tweedy streaming API: user filtering

I'm trying to just connect to the Twitter streaming API using tweepy (and python 3) and transfer all tweets from one user.

I had the impression that it was possible, so for this I need the following simple code:

 from tweepy import StreamListener from tweepy import Stream import tweepy auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) class StdOutListener(StreamListener): def on_data(self, data): # process stream data here print(data) def on_error(self, status): print(status) if __name__ == '__main__': listener = StdOutListener() twitterStream = Stream(auth, listener) twitterStream.filter(follow=['575930104']) 

When I run this from the command line, I just return a bunch of 406 codes from Twitter. Is there something very clearly wrong with the way I try to use tweepy, or is it a follow parameter that is not intended to do what I think it is doing?

EDIT: I also posted this on tweepy discussion boards, FYI.

+6
source share
1 answer

I was able to reproduce your problem in Python 3.4 using Tweepy 3.2.0. Upgrading to 3.3.0 solved the problem:

 $ bin/pip install -U tweepy==3.2.0 [...] Successfully installed tweepy requests-oauthlib six requests Cleaning up... $ bin/python test.py 406 ^CTraceback (most recent call last): [...] KeyboardInterrupt $ bin/pip install -U tweepy==3.3.0 [...] Successfully installed tweepy requests requests-oauthlib six Cleaning up... $ bin/python test.py {"created_at":"Fri Feb 27 14:02:02 +0000 2015","id":571309283217768448,"id_str":"571309283217768448", [...] 

Tweedy 3.3.0 Changelog mentions several stream improvements, although I did not see the β€œfreeze” problem they mention.

+7
source

Source: https://habr.com/ru/post/982967/


All Articles