-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunfollowers.py
63 lines (47 loc) · 1.7 KB
/
unfollowers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import instaloader
from instaloader import TwoFactorAuthRequiredException
import stdiomask
import os
def login_loader(username: str, password: str):
loader = instaloader.Instaloader()
try:
loader.login(username, password)
except TwoFactorAuthRequiredException:
os.system('cls')
print("2FA does not work on instaloader (bug). You'll have to disable it for now\n")
main()
# twofa = input('Insert your 2FA code: ')
# loader.two_factor_login(twofa)
return loader
def get_profile(username: str, loader):
profile = instaloader.Profile.from_username(loader.context, username)
return profile
def get_followed(profile):
followed = []
for followee in profile.get_followees():
followed.append(followee.username)
return followed
def get_followers(profile):
followers = []
for follower in profile.get_followers():
followers.append(follower.username)
return followers
def get_unfollowers(followers: list, followed: list):
unfollowers = []
for followee in followed:
if followee not in followers:
unfollowers.append(followee)
return unfollowers
def main():
login = input('Enter your Instagram username: ')
pw = stdiomask.getpass('Enter your password: ')
loader = login_loader(login, pw)
profile = get_profile(login, loader)
followed = get_followed(profile)
followers = get_followers(profile)
unfollowers = get_unfollowers(followers, followed)
print(f'Amount of unfollowers: {len(unfollowers)}')
for unfollower in unfollowers:
print(unfollower)
if __name__ == '__main__':
main()