Python tweepy 模块,StreamListener() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用tweepy.StreamListener()

项目:tensorflow_seq2seq_chatbot    作者:higepon    | 项目源码 | 文件源码
def tweet_listener():
    consumer_key = os.getenv("consumer_key")
    consumer_secret = os.getenv("consumer_secret")
    access_token = os.getenv("access_token")
    access_token_secret = os.getenv("access_token_secret")

    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth)

    while True:
        try:
            stream = tweepy.Stream(auth=api.auth,
                                   listener=StreamListener(api))
            print("listener starting...")
            stream.userstream()
        except Exception as e:
            print(e)
            print(e.__doc__)
项目:Seq2Seq-chatbot    作者:wataruhashimoto52    | 项目源码 | 文件源码
def tweet_listener():


    auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
    auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
    api = tweepy.API(auth)

    while True:
        try:
            stream = tweepy.Stream(auth=api.auth,
                                   listener=StreamListener(api))
            print("listener starting...")
            stream.userstream()
        except Exception as e:
            print(e)
            print(e.__doc__)
项目:Twitter-and-IMDB-Sentimental-Analytics    作者:abhinandanramesh    | 项目源码 | 文件源码
def __init__(self, api):
        self.api = api
        super(tweepy.StreamListener, self).__init__()
        client = KafkaClient("localhost:9092")
        self.producer = SimpleProducer(client, async = True,
                          batch_send_every_n = 1000,
                          batch_send_every_t = 10)
项目:aurora    作者:carnby    | 项目源码 | 文件源码
def __init__(self, fd, time_limit):
        """

        :param fd:
        :param time_limit: in seconds
        :return:
        """
        self.fd = fd
        self.time_limit = time_limit
        self.start_time = time.time()
        super(StreamListener, self).__init__()
项目:gdq-collector    作者:bcongdon    | 项目源码 | 文件源码
def __init__(self, handler):
        self.handler = handler
        tweepy.StreamListener.__init__(self)
项目:twitter-sentiment    作者:words-sdsc    | 项目源码 | 文件源码
def __init__(self, socketio):
        manager = CredentialsManager(settings.CREDENTIALS_PATH)
        cred = manager.read()

        auth = tweepy.OAuthHandler(cred['twitter_api_key'] ,
                                   cred['twitter_api_secret'])

        auth.set_access_token(cred['access_token'],
                              cred['access_token_secret'])
        self.stream = tweepy.Stream(auth, StreamListener(socketio))
项目:discursive    作者:Data4Democracy    | 项目源码 | 文件源码
def __init__(self, api=None):
        super(StreamListener, self).__init__()
        self.counter = 0
        self.limit = 500
        self.tweet_list = []
项目:discursive    作者:Data4Democracy    | 项目源码 | 文件源码
def search():
    stream_listener = StreamListener()
    stream = tweepy.Stream(auth=api.auth, listener=stream_listener)
    stream.filter(track=TOPICS)
    return
项目:Twitter-Sentiment-Analysis-Using-Spark-Streaming-And-Kafka    作者:sridharswamy    | 项目源码 | 文件源码
def __init__(self, api):
        self.api = api
        super(tweepy.StreamListener, self).__init__()
        client = KafkaClient("localhost:9092")
        self.producer = SimpleProducer(client, async = True,
                          batch_send_every_n = 1000,
                          batch_send_every_t = 10)
项目:Google-Finance-Stock-Data-Analysis    作者:hpnhxxwn    | 项目源码 | 文件源码
def __init__(self, api, producer, topic_name, symbols):
        """
        Listener initilizer
        :param api: tweepy api
        :param producer: Kafka producer
        :param topic_name: tweet topic the kafka producer sent by
        :param symbols: stock list
        :return: None
        """
        self.api = api    
        self.producer = producer
        self.topic_name = topic_name
        self.symbols = symbols
        super(tweepy.StreamListener, self).__init__()    
        print("Initiating Listener, topic is %s" % self.topic_name)
项目:geometrize-twitter-bot    作者:Tw1ddle    | 项目源码 | 文件源码
def __init__(self, api):
        super(tweepy.StreamListener, self).__init__()
        print("Will create Twitter stream listener")

        self.on_connect_cb = None
        self.on_timeout_cb = None
        self.on_error_cb = None
        self.on_status_cb = None

        self.api = api

        print("Did create Twitter stream listener")