• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python streaming.StreamListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tweepy.streaming.StreamListener的典型用法代码示例。如果您正苦于以下问题:Python StreamListener类的具体用法?Python StreamListener怎么用?Python StreamListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StreamListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, collection, stream_name, data_dir, seed=False, duration_minutes=15, tweets_per_record=25000):
        StreamListener.__init__(self)
        log.info("Streaming %s tweets for %s collection into %s. Rotating files every %s minutes. Rotating "
                 "records every %s tweets",
                 stream_name, collection, data_dir, duration_minutes, tweets_per_record)
        self.collection = collection
        self.stream_name = stream_name
        self.duration_minutes = duration_minutes
        self.tweets_per_record = tweets_per_record
        self.data_dir = data_dir
        self.seed = seed

        #Create data_dir
        if not os.path.exists(self.data_dir):
            os.makedirs(self.data_dir)

        self.period_start = None
        self.period_start_time = None
        self.warc = None
        self.warc_filepath = None
        self.segment_origin_id = None
        self.payload = ""
        self.segment = 1
        self.segment_total_length = 0
        self.tweet_count = 0
        #These will be set by StreamDecorator
        self.session = None
        self.url = None
开发者ID:gwu-libraries,项目名称:social-feed-harvester,代码行数:28,代码来源:twh.py


示例2: __init__

 def __init__(self, api=None, fobj=None):
     StreamListener.__init__(self, api)
     if fobj is None:
         fobj = sys.stdout
     self.fobj = fobj
     self.ratelimit = open('ratelimits.log', 'a')
     self.ratelimit.write('\n\n# Stream restarted on {0}'.format(time.strftime('%c')))
开发者ID:chebee7i,项目名称:twitter,代码行数:7,代码来源:stream.py


示例3: __init__

        def __init__(self,db_path,verbose,*args,**kwargs):
            self._verbose = verbose
            #setup database:
            self._conn = sqlite3.connect(options.db_path)
            c = self._conn.cursor()
            # Create table
#             c.execute('''CREATE TABLE IF NOT EXISTS GeoTweet
#                          (text text, lat real, lng real, time text, rt text, rt_count text, tw_id text)''')
            cmd = """
                CREATE TABLE IF NOT EXISTS "capture_geotweet" (
                    "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, -- table ID
                    "time" varchar(100) NOT NULL, -- time in string, e.g., "Sun Jun 22 14:24:56 +0000 2014"
                    "text" varchar(200) NOT NULL, -- content of tweet
                    "lat" decimal NOT NULL, -- latitude of tweet (all tweets in the database are geotagged)
                    "lng" decimal NOT NULL, -- longitude of tweet
                    "rt" bool NOT NULL,  -- whether the tweet was retweeted
                    "rt_count" integer NOT NULL, -- the number of times the tweet has been retweeted
                    "tw_id" varchar(50) NOT NULL -- the Twitter assigned ID
                , "epoch_time" integer);  -- time of tweet in seconds since Thursday Jan 1st, 1970 00:00:00 GMT
            """
            c.execute(cmd)
            self._conn.commit()
            self._time_format = '%a %b %d %H:%M:%S +0000 %Y'
            self._pattern = re.compile("[\W,.:/\']+")
            StreamListener.__init__(self,*args,**kwargs)
开发者ID:jamesmcinerney,项目名称:geotweet,代码行数:25,代码来源:tweepy_stream_sqlite.py


示例4: __init__

 def __init__(self, botname, taghandler, customhandler):
     self.botname = botname
     self.rsettag = re.compile(u"^@%s [email protected]?([a-zA-Z0-9_-]+) *[\=\=] *([^\s]+)$" % self.botname, re.IGNORECASE)
     self.rgettag = re.compile(u"^@%s [email protected]?([a-zA-Z0-9_-]+) *$" % self.botname, re.IGNORECASE)
     self.rdeltag = re.compile(u"^@%s +\/del +([^\s]+) *$" % self.botname, re.IGNORECASE)
     StreamListener.__init__(self)
     self.taghandler = taghandler
     self.customhandler = customhandler
开发者ID:felixonmars,项目名称:tagbot,代码行数:8,代码来源:tagbot.py


示例5: __init__

    def __init__(self, hashtags, session, engine):
        StreamListener.__init__(self)
        self.cpt = 0   # FIXME: test if useful
        self.eu = EncodingUtils()

        self.hashtags = self.format_hashtags(hashtags)
        self.session = session  # bridge to the db
        self.engine = engine
开发者ID:jlengrand,项目名称:twitterboard,代码行数:8,代码来源:streamer.py


示例6: __init__

 def __init__(self,timer):
     self.inc = 0
     StreamListener.__init__(self)
     # report the start of data collection...
     print "Gathering data at %s"%(str(ctime()))
     self.startTime = time()
     print "Start Time = %s"%(str(ctime()))
     self.timer = timer
     self.count = 0
开发者ID:umby,项目名称:hitsongpredictor,代码行数:9,代码来源:Echonestgenres.py


示例7: __init__

 def __init__(self,timer):
     self.inc = 0
     StreamListener.__init__(self)
     # report the start of data collection...
     print "Gathering data at %s"%(str(ctime()))
     self.startTime = time()
     print "Start Time = %s"%(str(ctime()))
     self.timer = timer
     self.count = 0
     self.conn = psycopg2.connect(database="postgres", user="postgres", password="pass", host="localhost", port="5432")
开发者ID:umby,项目名称:hitsongpredictor,代码行数:10,代码来源:song-stream-twitter.py


示例8: __init__

 def __init__(self,useBrowser,ofile,colorDict):
     StreamListener.__init__(self)
     self.useBrowser = useBrowser
     self.ofile = ofile
     (self.twMap,self.controller) = mapper.initMap(self.ofile,self.useBrowser)
     self.allCoordinates = []
     self.flog = codecs.open("log.txt",mode="w",encoding="utf-8")
     self.gcCount = 0
     self.tweetCount = 0
     self.colorDict = colorDict
开发者ID:PaulPGauthier,项目名称:Twitter-GoogleMaps,代码行数:10,代码来源:TweetListener.py


示例9: __init__

 def __init__(self, count=100):
     """
     creates a Custom Listener of Tweets that will end after a given amount of streamed Tweets
     :param count: number of Tweets to stream
     """
     # instantiating the super class StreamListener
     StreamListener.__init__(self)
     self.max_count = count
     self.counter = 0
     self.tweets = []
开发者ID:pauldechorgnat,项目名称:sandbox,代码行数:10,代码来源:tweet_storer.py


示例10: __init__

    def __init__(self, *args, **kwargs):
        state_dir = kwargs.pop('state_dir')
        self.post_replies = kwargs.pop('post_replies', False)
        self.gather = kwargs.pop('gather', None)
        StreamListener.__init__(self, *args, **kwargs)
        self.me = self.api.me()

        self._state = State.load(self.me.screen_name, state_dir)

        if self.gather:
            os.makedirs(self.gather, exist_ok=True)
开发者ID:wjt,项目名称:fewerror,代码行数:11,代码来源:__init__.py


示例11: __init__

 def __init__(self,timer):
     self.inc = 0
     StreamListener.__init__(self)
     # report the start of data collection...
     print "Gathering data at %s"%(str(ctime()))
     self.startTime = time()
     print "Start Time = %s"%(str(ctime()))
     ### When initialized, connects to MongoDB database tweets
     self.db=pymongo.MongoClient().tweets
     self.timer = timer
     self.count = 0
开发者ID:samuelkahn,项目名称:Datascience205,代码行数:11,代码来源:HW3_twitter_to_MongoDB.py


示例12: __init__

    def __init__(self, user_id_to_monitor, handle_status_callback):
        """ user_id_to_monitor: a valid Twitter user handle

            handle_status_callback: a callback that takes 
            (hashtag, originating_twitter_user_id, tweet) as parameters.
            
            The client callback will be invoked on every hashtag in a tweet
            that mentions it."""
                       
        StreamListener.__init__(self)
        self.user_id_to_monitor = user_id_to_monitor
        self.handle_status = handle_status_callback
开发者ID:voberoi,项目名称:loretweetmon,代码行数:12,代码来源:tweetmon.py


示例13: __init__

    def __init__(self, node, southwest, northeast, extras):

        logging.info("Beginning TwitterStreamer init")

        StreamListener.__init__(self)

        # Lock and target location
        self.lock = threading.Lock()
        self.buckets = {}
        self.deltas = {}
        self.uploaders = {}
        self.location = [southwest[LONG],southwest[LAT],northeast[LONG],northeast[LAT]]
        self.event_manager = EventManager()


        # Upload handler
        self.node = node

        logging.info("TwitterStreamer init successful")
开发者ID:andrewsosa001,项目名称:TweetEngine,代码行数:19,代码来源:twitter_streamer.py


示例14: __init__

 def __init__(self):
     StreamListener.__init__(self)
     self.destinations = []
开发者ID:adityadhakal,项目名称:twitter-analytics,代码行数:3,代码来源:TweetListener.py


示例15: __init__

 def __init__(self, handler_class, api=None, **opts):
     StreamListener.__init__(self)
     self.handler = handler_class(**opts)
开发者ID:bluele,项目名称:Twister,代码行数:3,代码来源:server.py


示例16: __init__

 def __init__(self, player, api=None):
     StreamListener.__init__(self, api)
     self._player = player
开发者ID:benijake,项目名称:twishogi,代码行数:3,代码来源:player.py


示例17: __init__

 def __init__(self):
     StreamListener.__init__(self)
     self.s3 = S3Connection(aws_access_key, aws_secret_key)
     self.start_new_tweet_file()
开发者ID:jmorales4,项目名称:W205-RJCL-Public,代码行数:4,代码来源:twitterStream.py


示例18: __init__

 def __init__(self, queue, *args, **kwargs):
     StreamListener.__init__(self, *args, **kwargs)
     self.queue = queue
开发者ID:b1naryth1ef,项目名称:livenlp,代码行数:3,代码来源:twitter.py


示例19: __init__

 def __init__(self, producer, count=10000, verbose=False):
     StreamListener.__init__(self)
     self.max_count = count
     self.counter = 0
     self.verbose = verbose
     self.producer = producer
开发者ID:pauldechorgnat,项目名称:sandbox,代码行数:6,代码来源:kafka_producer_for_twitter.py


示例20: __init__

 def __init__(self, monitor_these_user_ids, api=None):
     StreamListener.__init__(self)
     self.monitor_these_user_ids = monitor_these_user_ids
     self.pickle_file = open('/tmp/tweet_status.pickle', 'w')
开发者ID:greeness,项目名称:SmartTypes,代码行数:4,代码来源:get_twitter_tweets.py



注:本文中的tweepy.streaming.StreamListener类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.convert_to_utf8_str函数代码示例发布时间:2022-05-27
下一篇:
Python streaming.Stream类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap