Amazing-Python-Scripts

Форк
0
94 строки · 3.3 Кб
1
# IMPORTS
2
import requests
3
import argparse
4
import sys
5

6

7
def parser_input():
8
    """
9
    Function for Parsing the CLI input
10
    :return: parser.parse_args()  Parsed Arguments
11
    """
12
    parser = argparse.ArgumentParser()
13
    parser.add_argument("-u",
14
                        "--usernames",
15
                        help="Enter the username.",
16
                        type=str,
17
                        required=True)
18
    parser.add_argument("-t",
19
                        "--targets",
20
                        help="Enter the website(s). Use Lowercase only",
21
                        type=str,
22
                        required=True,
23
                        nargs='+')
24

25
    if len(sys.argv) == 1:
26
        parser.print_help()
27
        sys.exit()
28

29
    return parser.parse_args()
30

31

32
def inputs(usernames, targets):
33
    """
34
    Takes 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
    """
38
    username = usernames
39
    target = targets
40

41
    websites = {
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

60
    for key in websites.keys():
61
        keys = str(key)
62
        if keys == target:
63
            search_web(username, websites[keys])
64

65

66
def search_web(username, target_website):
67
    """
68
    The search web function
69
    :param username: Username to be searches across the platforms
70
    :param target_website: The targetted website
71
    """
72
    r = requests.get(target_website)
73
    if r.status_code == 200:
74
        print('Got it ' + username + ' in ' + target_website)
75
    elif r.status_code == 400:
76
        print('Error 400, Bad Request for ' + username + ' at ' +
77
              target_website + ' check the Syntax of the URL')
78
    elif r.status_code == 404:
79
        print('Error 404, Not Found ' + username + ' at ' + target_website)
80
    else:
81
        print('There seems to be a issue ' + username + ' at ' +
82
              target_website + ' is not responding. Check the'
83
              ' syntax of the URL.')
84

85

86
if __name__ == '__main__':
87
    print(
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")
92
    arg = parser_input()
93
    for i in range(len(arg.targets)):
94
        inputs(arg.usernames, arg.targets[i])
95

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.