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


Python Extractor.connectToAPI方法代碼示例

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


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

示例1: get_user_tweets

# 需要導入模塊: from extractor import Extractor [as 別名]
# 或者: from extractor.Extractor import connectToAPI [as 別名]
    def get_user_tweets(self,hashtaglist):


        ext= Extractor()
        auth = ext.loadtokens()
        api = ext.connectToAPI(auth)

        for ht in hashtaglist:

            full_tweets = ext.gettweets_hashtag(ht,api)
            ext.printcsv(full_tweets,ht)
開發者ID:cirnelle,項目名稱:TwitterML,代碼行數:13,代碼來源:get_tweets_by_hashtags.py

示例2: Extractor

# 需要導入模塊: from extractor import Extractor [as 別名]
# 或者: from extractor.Extractor import connectToAPI [as 別名]
        top_RT.append(t)


tweets.sort(key=lambda x:int(x[3]), reverse=True)


##Create list of most followed users##
for t in tweets:
    if (t[0] not in temp2) and (len(most_followed) < 200):
        temp2.append(t[0])
        most_followed.append([t[0], t[3]])

ext= Extractor()
auth = ext.loadtokens()
api = ext.connectToAPI(auth)

id_list=[]

print ("Getting ID of most retweeted tweets...")
## Get the ID of the most retweeted tweets and put them in a list##
## If tweet starts with 'RT', meaning it is a retweet, then get the ID of the original tweet ##
for t in top_RT:

    if (t[7].startswith('RT')) or (t[7].startswith('"RT')):

        tweet=api.get_status(id=int(t[1]))

        #dumps serialises strings into JSON (which is very similar to python's dict)
        json_str= json.dumps(tweet._json)
開發者ID:cirnelle,項目名稱:TwitterML,代碼行數:31,代碼來源:influencers.py


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