我正在使用tweepy
设置一个脚本,以查找我的用户名的最新提及。从这里,我想检索tweet的文本和他们的twitter用户名。但是,我似乎无法检索实际的@username,只有他们的ID号。有什么建议吗?
下面是我的代码。问号是我需要正确语法的地方:
myMentions = tweepy.Cursor (api.mentions).items(1)
for mention in myMentions:
statusText = mention.text
statusUser = mention.????
非常感谢!
最佳答案
以下是最新版本的适用于我的功能:
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
希望有帮助。