Tweepy - How to add user to specific list

限于喜欢 提交于 2019-12-13 03:16:36

问题


I'm trying to make multiple actions in one run retweet the tweets with a specific hashtag and add a user to list (already created list). I get to error message that

[{'code': 108, 'message': 'Cannot find specified user.'}]

# Import Tweepy, sleep, credentials.py
import tweepy
from time import sleep
from credentials import *

# Access and authorize our Twitter credentials from credentials.py
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

for tweet in tweepy.Cursor(api.search, q=('#ECM OR SPFx OR SharePoint'), lang='en').items(6):
    try:
        # Add \n escape character to print() to organize tweets
        print('\nTweet by: @' + tweet.user.screen_name)

        # Retweet tweets as they are found
        tweet.retweet()
        print('Retweeted the tweet')

        #Add to list
        api.add_list_member(screen_name='tweet.user.screen_name', slug='ListSlugName', owner_screen_name='@MyName')

        sleep(5)

    except tweepy.TweepError as e:
        print(e.reason)

    except StopIteration:
        break

来源:https://stackoverflow.com/questions/48809356/tweepy-how-to-add-user-to-specific-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!