I'm new to the tweepy
library. I am able to capture a twitter stream if I use a filter like the one shown below, looking for tweets containing the word snow in the text field.
import tweepy
ckey = ''
csecret = ''
atoken = ''
asecret = ''
auth = OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)
twitterStream = Stream(auth, listener())
twitterStream.filter(track=["snow"])
However, I don't know how to capture all tweets without doing any filtering. If I leave off the last line of the above code, the program runs, but I don't get any tweets. If I change the track parameter to track=[]
or track=[""]
, I receive an error code of 406 from the Twitter API.
I am using Python 3.4.2.
You can use twitterStream.sample()
as the last line for that. It will fetch all the tweets for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With