2017-07-15 67 views
1

我已經寫了這段代碼,它只是查看最近10條關於某個查詢的最新推文。我想以某種方式獲取它的最愛和轉發的數量。隨着tweepy你怎麼能得到最喜歡和轉推推文?

import tweepy 
import time 
import sys 

consumer_key='…' 
consumer_secret='…' 

access_token='…' 
access_token_secret='…' 

auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 
auth.set_access_token(access_token, access_token_secret) 

api = tweepy.API(auth) 

query="query" 

non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd) 

new_tweets = api.search(q=query,count=1) 
for tweet in new_tweets: 
    # Get favorites and retweets here 

WOM=new_tweets[0].created_at-new_tweets[len(new_tweets)-1].created_at 

回答

1

tweet.favorite_counttweet.retweet_count是你在找什麼。

+2

如果你想知道如何找出哪些特定的用戶喜歡或RTed推文......你不能。公共API不支持。 – duskwuff

+0

現在,我注意到用戶可能意味着要獲得所有RTs的數量,感謝您完成我的答案! –