Amazing-Python-Scripts
94 строки · 3.3 Кб
1# IMPORTS
2import requests3import argparse4import sys5
6
7def parser_input():8"""9Function for Parsing the CLI input
10:return: parser.parse_args() Parsed Arguments
11"""
12parser = argparse.ArgumentParser()13parser.add_argument("-u",14"--usernames",15help="Enter the username.",16type=str,17required=True)18parser.add_argument("-t",19"--targets",20help="Enter the website(s). Use Lowercase only",21type=str,22required=True,23nargs='+')24
25if len(sys.argv) == 1:26parser.print_help()27sys.exit()28
29return parser.parse_args()30
31
32def inputs(usernames, targets):33"""34Takes the various Inputs, Iterates over dictionary and invokes the search_web function
35:param usernames: Username to be searches across the platforms
36:param targets: The target websites. [nargs = '+', takes multiple inputs]
37"""
38username = usernames39target = targets40
41websites = {42"instagram": f'https://www.instagram.com/{username}',43"facebook": f'https://www.facebook.com/{username}',44"twitter": f'https://twitter.com/{username}',45"youtube": f'https://www.youtube.com/{username}',46"reddit": f'https://www.reddit.com/user/{username}',47"blogger": f'https://{username}.blogspot.com',48"github": f'https://www.github.com/{username}',49"steam": f'https://steamcommunity.com/id/{username}',50"soundcloud": f'https://soundcloud.com/{username}',51"medium": f'https://medium.com/@{username}',52"spotify": f'https://open.spotify.com/user/{username}',53"patreon": f'https://www.patreon.com/{username}',54"bitbucket": f'https://bitbucket.org/{username}',55"goodreads": f'https://www.goodreads.com/{username}',56"wikipedia": f'https://www.wikipedia.org/wiki/User:{username}',57"slack": f'https://{username}.slack.com'58}59
60for key in websites.keys():61keys = str(key)62if keys == target:63search_web(username, websites[keys])64
65
66def search_web(username, target_website):67"""68The search web function
69:param username: Username to be searches across the platforms
70:param target_website: The targetted website
71"""
72r = requests.get(target_website)73if r.status_code == 200:74print('Got it ' + username + ' in ' + target_website)75elif r.status_code == 400:76print('Error 400, Bad Request for ' + username + ' at ' +77target_website + ' check the Syntax of the URL')78elif r.status_code == 404:79print('Error 404, Not Found ' + username + ' at ' + target_website)80else:81print('There seems to be a issue ' + username + ' at ' +82target_website + ' is not responding. Check the'83' syntax of the URL.')84
85
86if __name__ == '__main__':87print(88"Hello User, Using this script, yu can search for usernames across social media networks.\n"89"Important, enter only one username at once.\n"90"Enter as many as required supported platforms (SEE README).\n"91"Enter the platform in lower case. ONLY.\n")92arg = parser_input()93for i in range(len(arg.targets)):94inputs(arg.usernames, arg.targets[i])95