提到的Tweepy用户标识

2024-05-29 05:54:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用tweepy来设置一个脚本,该脚本可以找到最新提到的我的用户名。从这里,我想检索tweet的文本,以及他们的twitter用户名。但是,我似乎无法检索到实际的@username,只有他们的id号码。有什么建议吗?在

下面是我的代码。问号是我需要正确语法的地方:

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

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

非常感谢!在


Tags: 代码文本脚本id语法usernametwitter建议
1条回答
网友
1楼 · 发布于 2024-05-29 05:54:46

以下是我最新的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

希望有帮助。在

相关问题 更多 >

    热门问题