ツイッターのフォロワーすべてをリストに追加します。
import tweepy from datetime import datetime # Twitter APIの認証情報を設定する consumer_key = "YOUR_CONSUMER_KEY" consumer_secret = "YOUR_CONSUMER_SECRET" access_token = "YOUR_ACCESS_TOKEN" access_token_secret = "YOUR_ACCESS_TOKEN_SECRET" # Tweepyを使用して認証情報を設定する auth = tweepy.OAuth1UserHandler( consumer_key, consumer_secret, access_token, access_token_secret) # TweepyのAPIオブジェクトを作成する api = tweepy.API(auth) # 現在認証されたアカウントのユーザーIDを取得する user_id = api.me().id_str # リスト名を作成する list_name = datetime.now().strftime("%Y%m%d_%H%M%S") # 新しいリストを作成する new_list = api.create_list(name=list_name, mode="private") # 現在認証されたアカウントのフォロワーのIDを取得する followers = tweepy.Cursor(api.followers_ids, user_id=user_id).items() # フォロワーを新しいリストに追加する for follower_id in followers: api.add_list_member(list_id=new_list.id_str, user_id=follower_id)