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


Python Collector.stream方法代碼示例

本文整理匯總了Python中collector.Collector.stream方法的典型用法代碼示例。如果您正苦於以下問題:Python Collector.stream方法的具體用法?Python Collector.stream怎麽用?Python Collector.stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在collector.Collector的用法示例。


在下文中一共展示了Collector.stream方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from collector import Collector [as 別名]
# 或者: from collector.Collector import stream [as 別名]
def main():
    creds = Credentials(os.path.expanduser('~/.tweepy'))
    today = datetime.date.today()
    week = datetime.timedelta(7)
    query_terms=['#NBAFinals2015', '#Warriors'] 
    query_ops={}
    query_ops['lang'] = 'en'
    stream = False;
    if stream:
        auth = tweepy.OAuthHandler(creds.consumer_key, creds.consumer_secret)
        auth.set_access_token(creds.access_token, creds.access_token_secret)
        query_ops['until'] = today+week
    else:
        #Per Ron Cordell's suggestion, use App Auth token for increased limits
        auth = tweepy.AppAuthHandler(creds.consumer_key, creds.consumer_secret)
        query_ops['since'] = today-week
        query_ops['until'] = today
        query_ops['result_type'] = 'recent'
    collector = Collector(auth)
    if stream:
        print("Starting streaming")
        collector.stream(query_terms=query_terms,
                  query_ops=query_ops)
    else:
        print("Starting search")
        collector.search(query_terms=query_terms,
                  query_ops=query_ops)
    print('All done!  Last ID processed={0}'.format(collector.last_id))
開發者ID:nkrishnaswami,項目名稱:mids-w205-hw2,代碼行數:30,代碼來源:acq.py


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