Created
December 17, 2022 18:11
-
-
Save yayoimizuha/c2b8ddde1c428a7f2c797bb2b4028614 to your computer and use it in GitHub Desktop.
アクセストークンと、ユーザー名適宜指定して実行してください、ツイート数が10件未満で自分がフォローしてないアカウントが列挙されますので、yを押すとブロックされます。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import environ | |
from tweepy import OAuth1UserHandler, API, Cursor, errors | |
auth = OAuth1UserHandler( | |
consumer_key=environ["CLIENT_ID"], | |
consumer_secret=environ["CLIENT_SECRET"], | |
access_token=environ["ACCESS_TOKEN"], | |
access_token_secret=environ["ACCESS_TOKEN_SECRET"] | |
) | |
api = API(auth=auth, wait_on_rate_limit=True) | |
for account_id in Cursor(api.get_followers, screen_name="yayoi_mizuha", count=200). \ | |
items(api.get_user(screen_name="yayoi_mizuha").followers_count): | |
if not account_id.following and account_id.statuses_count < 10: | |
print("\n\n") | |
print(f"@{account_id.screen_name}") | |
print(account_id.name) | |
# print(account_id.statuses_count) | |
print(f"フォロワー数:{account_id.followers_count}") | |
print(f"フォロー数:{account_id.friends_count}") | |
print(account_id.description) | |
if input().upper() == "Y": | |
try: | |
api.create_block(screen_name=account_id.screen_name) | |
except errors.NotFound as e: | |
print(e) | |
print(f"blocked: https://twitter.com/{account_id.screen_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment