Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use tweepy without a filter

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.

like image 227
singrass Avatar asked Dec 17 '14 16:12

singrass


1 Answers

You can use twitterStream.sample() as the last line for that. It will fetch all the tweets for you.

like image 140
Aditya Saxena Avatar answered Oct 01 '22 06:10

Aditya Saxena