【问题标题】:Tweepy user id from mention提到的 Tweepy 用户 ID
【发布时间】:2013-04-28 22:38:34
【问题描述】:

我正在使用tweepy 来设置一个脚本来查找我的用户名的最新提及。从这里,我想检索推文的文本,以及他们的推特用户名。但是,我似乎无法检索实际的@用户名,只能检索他们的 ID 号。有什么建议吗?

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

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

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

非常感谢!

【问题讨论】:

    标签: python twitter tweepy


    【解决方案1】:

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

    希望对您有所帮助。

    【讨论】:

    • 可爱,代码第一次为我工作,在 2014 年 3 月! :v
    • 您能告诉我如何使用 tweepy 获取一些提及时间线。就像将参数传递为 Id=''
    • @alecxe 我们有什么办法可以修改它以获得最新的提及?
    猜你喜欢
    • 2015-05-27
    • 2017-08-14
    • 2022-11-16
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2019-02-11
    • 2018-03-17
    • 2018-04-29
    相关资源
    最近更新 更多