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