相关疑难解决方法(0)

Tweepy Streaming - 停止以x金额收集推文

我想在MongoDB中存储x#推文之后,让Tweepy Streaming API停止推文.

我已经在类中尝试了IF和WHILE语句,使用计数器进行了定义,但是无法让它在某个X量上停止.对我来说,这真是一个真正的头脑.我在这里找到了这个链接:https://groups.google.com/forum/#!topic/tvweepy/5IGlu2Qiug4 但是我复制这个的努力失败了.它总是告诉我init需要一个额外的参数.我相信我们的Tweepy auth设置不同,所以它不是苹果到苹果.

有什么想法吗?

from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
import json, time, sys

import tweepy
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

class StdOutListener(StreamListener):

    def on_status(self, status):
        text = status.text
        created = status.created_at
        record = {'Text': text, 'Created At': created}
        print record #See Tweepy documentation to learn how to access other fields
        collection.insert(record)  


    def on_error(self, status):
        print 'Error on status', status

    def on_limit(self, status):
        print 'Limit …
Run Code Online (Sandbox Code Playgroud)

python twitter tweepy

5
推荐指数
1
解决办法
9973
查看次数

标签 统计

python ×1

tweepy ×1

twitter ×1