これの流し読みとGPT4でコード生成()しましたが、API申請するのめんどくさくてやってません 誰か検証してください Twitter APIドキュメント | Docs | Twitter Developer Platform
import tweepy # Twitter API credentials consumer_key = "YOUR_CONSUMER_KEY" consumer_secret = "YOUR_CONSUMER_SECRET" access_token = "YOUR_ACCESS_TOKEN" access_token_secret = "YOUR_ACCESS_TOKEN_SECRET" def main(): # Authenticate to Twitter auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) # Create API object api = tweepy.API(auth) # Search for users with 'AI研究' in their bio search_query = 'AI研究' users = tweepy.Cursor(api.search_users, q=search_query).items() # Block each user in the list for user in users: print(f"Blocking user: {user.screen_name}") api.create_block(user.id) if __name__ == "__main__": main()