Reputation: 72
I'm trying to stream tweets from twitter using Tweepy for a particular hashtag. The problem that I'm facing is that fetching 500 tweets is taking almost around 10-15 minutes. I don't think it is supposed to be that slow? Am I missing anything? Has it got to do with any API rate limits? My tweepy listener looks like this:
class MyListener(StreamListener): """Custom StreamListener for streaming data."""
def __init__(self, lim):
self.count = 0
self.limit = lim
def on_data(self, data):
global tweets
if self.count < self.limit:
try:
self.count += 1
tweets.append(data)
return True
except BaseException, e:
print 'failed ondata,', str(e)
time.sleep(5)
pass
else:
return False
def on_error(self, status):
print(status)
return True
Upvotes: 0
Views: 1293
Reputation: 555
You are trying to fetch live tweets. It means the rate of your collecting tweets is the rate in which people post tweets with that hashtag. You can try your code with a popular or trending hashtag and you will get outputs faster.
Upvotes: 1