-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
284 lines (238 loc) · 9.78 KB
/
Copy pathsetup.py
File metadata and controls
284 lines (238 loc) · 9.78 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
from getpass import getpass
import instaloader
import urllib3
import socket
from fileinput import close
import re
import csv
from time import sleep
import os
import sys
import pathlib
from timeit import default_timer as timer
import datetime
import time
import progressbar
from colorama import init
from termcolor import colored
init()
# Get instance
L = instaloader.Instaloader()
def cekkoneksi():
while True:
try:
widgets = ['Cek Internet ..', progressbar.AnimatedMarker()]
bar = progressbar.ProgressBar(widgets=widgets).start()
for i in range(20):
time.sleep(0.1)
bar.update(i)
socket.create_connection(('instagram.com', 80))
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
print(colored('Berhasil Terhubung Ke Instagram', 'green'))
time.sleep(1)
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
return
except:
print('Tidak Ada Internet.\n Dimulai kembali dalam 5 detik.\n')
sleep(5)
def ceklogin():
ceklogin = 'false'
while (ceklogin == 'false'):
print(colored('Terhubung Ke Instagram', 'green'))
print(
'--------------------------------------------------------------------------------\n')
print(
colored('**-- Aplikasi Scrab Data Followers By Fembi Nur Ilham --**', 'white'))
print(
'--------------------------------------------------------------------------------\n')
print("Masukkan Akun Instagram Untuk Login")
print('')
username = input("Username : ")
password = getpass("Password : ")
try:
print('')
widgets = ['Mencoba Login ..', progressbar.AnimatedMarker()]
bar = progressbar.ProgressBar(widgets=widgets).start()
for i in range(20):
time.sleep(0.1)
bar.update(i)
L.login(username, password)
ceklogin = 'true'
time.sleep(5)
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
print(
colored('Berhasil Login', 'green')
)
print(
'--------------------------------------------------------------------------------\n')
print(
colored('**-- Aplikasi Scrab Data Followers By Fembi Nur Ilham --**', 'white'))
print(
'--------------------------------------------------------------------------------\n')
except:
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
print(colored('Login Tidak Berhasil', 'red'))
def progress(percent=0, width=40):
left = width * percent // 100
right = width - left
tags = "#" * left
spaces = " " * right
percents = f"{percent:.0f}%"
print("\r[", tags, spaces, "]", percents, sep="", end="", flush=True)
def cekakunterakhir(name):
akunakhir = 'false'
while (akunakhir == 'false'):
konfirmasi = input(
"Lanjutkan Proses Sebelumnya, Ketik 'ya' Untuk Melanjutkan: ")
if konfirmasi == 'ya':
try:
filename = 'downloads/'+name+'.csv'
dtuser = []
with open(filename, 'r', newline='', encoding="utf-8") as csvf:
file_read = csv.reader(csvf)
for row in file_read:
dtuser.append(row[1])
print('Akun Terahir :' + dtuser[-1])
return dtuser[-1]
except:
print('Gagal Mengambil File')
akunakhir = 'true'
fileterakhir = ''
return fileterakhir
else:
terakhir = ''
print('Memulai dari awal')
return terakhir
cekkoneksi()
ceklogin()
print("Akun Instagram Yang Akan Diambil Followersnya")
akun = input("Akun : ")
print('')
terakhir = cekakunterakhir(akun)
print('--------------------------------------------------------------------------------\n')
time.sleep(5)
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
# Mengambil directory
pathlib.Path('downloads/').mkdir(parents=True, exist_ok=True)
http = urllib3.PoolManager()
start = timer()
curr = str(datetime.datetime.now())
# Akun Scrab
accounts = akun
p = accounts.split('\n')
# Akun Terakhir
last = terakhir
last = last.strip()
for profile in p:
if last in profile and len(last) > 2:
print(last, profile)
p.remove(profile)
print(
colored('Target : ' + akun, 'white')
)
print(
'--------------------------------------------------------------------------------\n')
print(
colored('**-- Aplikasi Scrab Data Followers By Fembi Nur Ilham --**', 'white'))
print(
'--------------------------------------------------------------------------------\n')
print('Mengambil Data:', p[0])
PROFILE = p[:]
print(PROFILE)
print('Total Akun Yang Akan Diambil:', len(PROFILE))
print('--------------------------------------------------------------------------------\n')
for ind in range(len(PROFILE)):
pro = PROFILE[ind]
try:
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
widgets = ['Mendapatkan Data Follwers Dari '+pro+' ...',
progressbar.AnimatedMarker()]
bar = progressbar.ProgressBar(widgets=widgets).start()
for i in range(20):
time.sleep(0.1)
bar.update(i)
filename = 'downloads/'+pro+'.csv'
with open(filename, 'a', newline='', encoding="utf-8") as csvf:
csv_writer = csv.writer(csvf)
csv_writer.writerow(['user_id', 'username', 'Nama Lengkap', 'Akun verified', 'Akun private', 'Total Media',
'Totol Pengikut', 'Total Mengikuti', 'Bio', 'Website', 'Email', 'Last Activity', 'IGtv_count', 'Akun Bisnis', 'Nama bisnis', 'Foto Profil', 'scrape_of', 'scraped_at'])
profile = instaloader.Profile.from_username(L.context, pro)
main_followers = profile.followers
count = 0
total = 0
for person in profile.get_followers():
dtuser = []
with open(filename, 'r', newline='', encoding="utf-8") as csvf:
file_read = csv.reader(csvf)
for row in file_read:
dtuser.append(row[1])
cek = 'true'
for cekuser in dtuser:
if cekuser == person.username:
cek = 'false'
print('')
print(person.username + ' Telah Ada')
print('')
if cek == 'true':
try:
total += 1
user_id = person.userid
username = person.username
fullname = person.full_name
is_verified = person.is_verified
is_private = person.is_private
media_count = person.mediacount
follower_count = person.followers
following_count = person.followees
bio = person.biography
emails = re.findall(
r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", bio)
website = person.external_url
igtv_count = person.igtvcount
is_business_account = person.is_business_account
business_category_name = person.business_category_name
profile_pic_url = person.profile_pic_url
# last activity
try:
follower_profile = instaloader.Profile.from_username(
L.context, username)
for post in follower_profile.get_posts():
last_activity = post.date_local
break
except Exception as e:
# print(e)
last_activity = ''
with open(filename, 'a', newline='', encoding="utf-8") as csvf:
csv_writer = csv.writer(csvf)
csv_writer.writerow([user_id, username, fullname, is_verified, is_private, media_count,
follower_count, following_count, bio, website, emails, last_activity, igtv_count, is_business_account, business_category_name, profile_pic_url, pro, curr])
os.system('clear')
os.system('cls' if os.name == 'nt' else 'clear')
print(
colored('Target : ' + akun, 'white')
)
print(
'--------------------------------------------------------------------------------\n')
print(
colored('**-- Aplikasi Scrab Data Followers By Fembi Nur Ilham --**', 'white'))
print(
'--------------------------------------------------------------------------------\n')
print('Total akun berhasil diambil:',
total, ' dari', main_followers)
print('Username:', username)
# print('Persen:', round(total/main_followers*100), '%')
print('Waktu:', str(datetime.timedelta(
seconds=(round(timer()-start)))))
# print('Current Account:', ind+1, '\t Remaining Accounts:', len(PROFILE)-ind-1, '\nAccount Name:', pro)
progress(round(total/main_followers*100))
except Exception as e:
print(e)
# (likewise with profile.get_followers())
except:
print('Skipping', pro)