2013-05-04 37 views
6

我使用tweepy來設置一個腳本,該腳本查找最新提及的用戶名。由此,我想檢索推文的文本,以及他們的推特用戶名。但是,我似乎無法檢索實際的@用戶名,只有他們的ID號。有什麼建議麼?從提及的Tweepy用戶標識

以下是我的代碼。問號是我需要正確語法的地方:

myMentions = tweepy.Cursor (api.mentions).items(1) 

for mention in myMentions: 
    statusText = mention.text 
    statusUser = mention.???? 

非常感謝!

回答

9

下面是我什麼工作與最新版本tweepy

import tweepy 

auth = tweepy.OAuthHandler(<consumer_key>, <consumer_secret>) 
auth.set_access_token(<key>, <secret>) 

api = tweepy.API(auth) 

mentions = api.mentions_timeline(count=1) 

for mention in mentions: 
    print mention.text 
    print mention.user.screen_name 

希望有所幫助。

+0

可愛的代碼第一次爲我工作,2014年3月! :v – Adjam 2014-03-20 16:59:31

+0

你可以請告訴如何使用tweepy獲取一些mentions_time行。就像傳遞參數一樣,Id ='' – 2015-01-24 20:08:38

+0

@alecxe有沒有什麼辦法可以修改這個來得到最新的提及? – bholagabbar 2016-07-07 19:52:13

相關問題