-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDriverGetAcc.py
98 lines (87 loc) · 2.88 KB
/
DriverGetAcc.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from threading import Thread, Lock
import instaloader
from instaloader.exceptions import BadCredentialsException, ConnectionException, BadResponseException
from time import sleep, time
class ChromeDriverGetAccount:
stopped = True
lock = None
t = None
browser = None
username = ""
password = ""
url = ""
userList = []
getState = False
errorMessageState = False
errorMessage = ""
finishTime = 0
def __init__(self, username, password, url):
self.lock = Lock()
self.username = username
self.password = password
self.url = url
self.timer = time()
def resetSelfs(self):
self.lock.acquire()
self.errorMessageState = False
self.getState = False
self.lock.release()
def bot(self):
self.browser = instaloader.Instaloader()
try:
self.browser.login(user=self.username, passwd=self.password)
shortcode = self.url
try:
shortcode = shortcode.split("/")
if shortcode[-1] == "":
shortcode = shortcode[-2]
else:
shortcode = shortcode[-1]
except:
pass
try:
Post = instaloader.Post.from_shortcode(self.browser.context, shortcode)
except BadResponseException as badRes:
print(f"{badRes}")
self.lock.acquire()
self.errorMessageState = True
self.errorMessage = "Lütfen urlyi düzeltiniz..."
self.lock.release()
users = []
for like in Post.get_likes():
if self.stopped:
break
if like not in users:
try:
like_ = str(like).split(" ")[1]
except:
like_ = str(like)
users.append(like_)
sn = time() - self.timer
self.lock.acquire()
self.getState = True
self.userList = users
self.finishTime = sn
self.lock.release()
except ConnectionException as con:
print(f"{con}")
self.lock.acquire()
self.errorMessageState = True
self.errorMessage = "Giriş başarısız..\nLütfen tekrar deneyiniz..."
self.lock.release()
except BadCredentialsException as bad:
print(f"{bad}")
self.lock.acquire()
self.errorMessageState = True
self.errorMessage = "Kullanıcı adı ve/veya Şifre Hatalı.."
self.lock.release()
def start(self):
self.stopped = False
self.t = Thread(target=self.run)
self.t.start()
def stop(self):
self.stopped = True
self.t.join()
def run(self):
if not self.stopped:
self.bot()