在推文中提及所有用户及其用户ID

时间:2019-07-31 23:08:12

标签: python tweepy

当我搜索包含某些单词的推文时,我想检查那些在推文中提到的专门说“关注@someoneSo”的用户,以便跟踪它们并查看他们的个人资料(如果它们看起来像是相关帐户),并希望遵循我在结尾处喜欢的一些叙述。

是否有与Discord的message.mentions.users类似的地方,它返回推文中提到的用户列表?

例如,如果一条tweet text ='dvffegregre rg ADQEW跟随@chad @lee efkneknen'或tweet text ='dvffegregre rg ADQEW跟随这些家伙@chad @lee efkneknen',我的脚本将能够跟随@chad和@lee

1 个答案:

答案 0 :(得分:1)

text = 'dvffegregre rg ADQEW follow @chad @lee efkneknen'
textlist = text.split(' ')
users = []
if 'follow' in textlist:
    for subtext in textlist:
        if subtext.startswith('@'):
            API.create_friendship(subtext.strip('@'))

我认为这应该适合您的目的。