Untitled
unknown
python
6 months ago
1.1 kB
9
Indexable
import asyncio from twikit import Client import re USERNAME = '' EMAIL = '' PASSWORD = '' # Initialize client client = Client('en-US') def check_url_in_string(string): url_regex = r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" return bool(re.search(url_regex, string)) async def main(): await client.login( auth_info_1=USERNAME, auth_info_2=EMAIL, password=PASSWORD ) # Get user id from screen name userId = (await client.get_user_by_screen_name(USERNAME)).id # Get user followers by user id userFolowers = await client.get_user_followers(userId) # Parse followers for bot features for follower in userFolowers: if (not follower.description or check_url_in_string(follower.description)) \ and (follower.followers_count < 50 or follower.following_count / follower.followers_count > 20): await client.block_user(follower.id) # user has no descripton or description contains link and nonsensical following,followers if __name__ == '__main__': asyncio.run(main())
Editor is loading...
Leave a Comment