问题描述:

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

网友答案:

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.

相关阅读:
Top