您的位置 首页 Python

python – 来自提及的Tweepy用户ID

我正在使用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

希望有所帮助.

关于作者: dawei

【声明】:金华站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

热门文章