當前位置: 首頁>>代碼示例>>Python>>正文


Python streaming.StreamListener類代碼示例

本文整理匯總了Python中tweepy.streaming.StreamListener的典型用法代碼示例。如果您正苦於以下問題:Python StreamListener類的具體用法?Python StreamListener怎麽用?Python StreamListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了StreamListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的tweepy.streaming.StreamListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。