Twitter Stream 不适用于 Tweepy

Twitter Stream not working for Tweepy

使用下面的代码,我正在尝试获取哈希标签。它适用于像#StarWars 这样的大型搜索,但当我要求较小的搜索时,它似乎 return 什么都没有。

想法?

'code' 用于代替实际的身份验证字符串

from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
from textwrap import TextWrapper
import json

access_token = "code"
access_token_secret = "code"
consumer_key = "code"
consumer_secret = "code"

class StdOutListener(StreamListener):
    ''' Handles data received from the stream. '''

    status_wrapper = TextWrapper(width=60, initial_indent='    ', subsequent_indent='    ')

    def on_status(self, status):
        try:
            print self.status_wrapper.fill(status.text)
            print '\n %s  %s  via %s\n' % (status.author.screen_name, status.created_at, status.source)
        except:
            # Catch any unicode errors while printing to console
            # and just ignore them to avoid breaking application.
            pass

    def on_error(self, status_code):
        print('Got an error with status code: ' + str(status_code))
        return True # To continue listening

    def on_timeout(self):
        print('Timeout...')
        return True # To continue listening

if __name__ == '__main__':
    listener = StdOutListener()
    auth = OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)

    stream = Stream(auth, listener)
    stream.filter(track=['#TestingPythonTweet'])

好的,所以我发现这个问题的答案是我期待它可以追溯工作。这是我的根本错误。相反,实际发生的是它获得了 当前 正在推特上的内容。以前不是。