■ ■ ■ ■ ■ ■
src/commands/fwersemail/run.py
| 1 | + | import yaml |
| 2 | + | import readline |
| 3 | + | import signal |
| 4 | + | from prettytable import PrettyTable |
| 5 | + | from src import printcolors as pc |
| 6 | + | from src import utils as utils |
| 7 | + | import json |
| 8 | + | import sys |
| 9 | + | import time |
| 10 | + | |
| 11 | + | from src.CommandFather import CommandFather |
| 12 | + | from instagram_private_api import ClientThrottledError |
| 13 | + | |
| 14 | + | |
| 15 | + | class Command(CommandFather): |
| 16 | + | |
| 17 | + | def __init__(self, status, api): |
| 18 | + | super().__init__(status) |
| 19 | + | self.status = status |
| 20 | + | self.osintgram = api |
| 21 | + | |
| 22 | + | def run(self): |
| 23 | + | if self.osintgram.check_private_profile(): |
| 24 | + | return |
| 25 | + | |
| 26 | + | pc.printout("Searching for " + self.osintgram.target + " followers...\n") |
| 27 | + | |
| 28 | + | followers = [] |
| 29 | + | results = [] |
| 30 | + | |
| 31 | + | try: |
| 32 | + | |
| 33 | + | rank_token = self.osintgram.generate_uuid() |
| 34 | + | data = self.osintgram.get_api().user_followers(str(self.osintgram.target_id), rank_token=rank_token) |
| 35 | + | |
| 36 | + | for user in data.get('users', []): |
| 37 | + | u = { |
| 38 | + | 'id': user['pk'], |
| 39 | + | 'username': user['username'], |
| 40 | + | 'full_name': user['full_name'] |
| 41 | + | } |
| 42 | + | followers.append(u) |
| 43 | + | |
| 44 | + | next_max_id = data.get('next_max_id') |
| 45 | + | while next_max_id: |
| 46 | + | if(int(super().get_option('output_limit')) > 0 and len(followers) >= int(super().get_option('output_limit'))): |
| 47 | + | break |
| 48 | + | |
| 49 | + | if(int(super().get_option('delay')) > 0): |
| 50 | + | time.sleep(int(super().get_option('delay'))) |
| 51 | + | |
| 52 | + | sys.stdout.write("\rCatched %i followers" % len(followers)) |
| 53 | + | sys.stdout.flush() |
| 54 | + | data = self.osintgram.get_api().user_followers(str(self.osintgram.target_id), rank_token=rank_token, max_id=next_max_id) |
| 55 | + | |
| 56 | + | for user in data.get('users', []): |
| 57 | + | u = { |
| 58 | + | 'id': user['pk'], |
| 59 | + | 'username': user['username'], |
| 60 | + | 'full_name': user['full_name'] |
| 61 | + | } |
| 62 | + | followers.append(u) |
| 63 | + | |
| 64 | + | next_max_id = results.get('next_max_id') |
| 65 | + | |
| 66 | + | sys.stdout.write("\rCatched %i followers\n" % len(followers)) |
| 67 | + | sys.stdout.flush() |
| 68 | + | |
| 69 | + | for follow in followers: |
| 70 | + | if(int(super().get_option('output_limit')) > 0 and len(results) >= int(super().get_option('output_limit'))): |
| 71 | + | break |
| 72 | + | |
| 73 | + | sys.stdout.write("\rCatched %i followers email" % len(results)) |
| 74 | + | sys.stdout.flush() |
| 75 | + | |
| 76 | + | if(int(super().get_option('delay')) > 0): |
| 77 | + | time.sleep(int(super().get_option('delay'))) |
| 78 | + | |
| 79 | + | user = self.osintgram.get_api().user_info(str(follow['id'])) |
| 80 | + | if 'public_email' in user['user'] and user['user']['public_email']: |
| 81 | + | follow['email'] = user['user']['public_email'] |
| 82 | + | results.append(follow) |
| 83 | + | sys.stdout.write("\rCatched %i followers email" % len(results)) |
| 84 | + | sys.stdout.flush() |
| 85 | + | |
| 86 | + | except ClientThrottledError as e: |
| 87 | + | utils.print_error("\nError: Instagram blocked the requests. Please wait a few minutes before you try again.") |
| 88 | + | |
| 89 | + | if len(results) > 0: |
| 90 | + | self.status.print_output(results, ['ID', 'Username', 'Full Name', 'Email'], ['id', 'username', 'full_name', 'email']) |
| 91 | + | else: |
| 92 | + | pc.printout("Sorry! No results found :-(\n", pc.RED) |
| 93 | + | |