@@ -31,7 +31,7 @@ class Osintgram:
31
31
writeFile = False
32
32
jsonDump = False
33
33
34
- def __init__ (self , target , is_file , is_json , is_cli ):
34
+ def __init__ (self , target , is_file , is_json , is_cli , output_dir ):
35
35
u = config .getUsername ()
36
36
p = config .getPassword ()
37
37
if not is_cli :
@@ -150,14 +150,14 @@ def get_addrs(self):
150
150
i = i + 1
151
151
152
152
if self .writeFile :
153
- file_name = "output /" + self .target + "_addrs.txt"
153
+ file_name = output_dir + " /" + self .target + "_addrs.txt"
154
154
file = open (file_name , "w" )
155
155
file .write (str (t ))
156
156
file .close ()
157
157
158
158
if self .jsonDump :
159
159
json_data ['address' ] = addrs_list
160
- json_file_name = "output /" + self .target + "_addrs.json"
160
+ json_file_name = output_dir + " /" + self .target + "_addrs.json"
161
161
with open (json_file_name , 'w' ) as f :
162
162
json .dump (json_data , f )
163
163
@@ -200,7 +200,7 @@ def get_captions(self):
200
200
file = None
201
201
202
202
if self .writeFile :
203
- file_name = "output /" + self .target + "_captions.txt"
203
+ file_name = output_dir + " /" + self .target + "_captions.txt"
204
204
file = open (file_name , "w" )
205
205
206
206
for s in captions :
@@ -211,7 +211,7 @@ def get_captions(self):
211
211
212
212
if self .jsonDump :
213
213
json_data ['captions' ] = captions
214
- json_file_name = "output /" + self .target + "_followings.json"
214
+ json_file_name = output_dir + " /" + self .target + "_followings.json"
215
215
with open (json_file_name , 'w' ) as f :
216
216
json .dump (json_data , f )
217
217
@@ -239,7 +239,7 @@ def get_total_comments(self):
239
239
posts += 1
240
240
241
241
if self .writeFile :
242
- file_name = "output /" + self .target + "_comments.txt"
242
+ file_name = output_dir + " /" + self .target + "_comments.txt"
243
243
file = open (file_name , "w" )
244
244
file .write (str (comments_counter ) + " comments in " + str (posts ) + " posts\n " )
245
245
file .close ()
@@ -249,7 +249,7 @@ def get_total_comments(self):
249
249
'comment_counter' : comments_counter ,
250
250
'posts' : posts
251
251
}
252
- json_file_name = "output /" + self .target + "_comments.json"
252
+ json_file_name = output_dir + " /" + self .target + "_comments.json"
253
253
with open (json_file_name , 'w' ) as f :
254
254
json .dump (json_data , f )
255
255
@@ -285,13 +285,13 @@ def get_comment_data(self):
285
285
286
286
print (t )
287
287
if self .writeFile :
288
- file_name = "output /" + self .target + "_comment_data.txt"
288
+ file_name = output_dir + " /" + self .target + "_comment_data.txt"
289
289
with open (file_name , 'w' ) as f :
290
290
f .write (str (t ))
291
291
f .close ()
292
292
293
293
if self .jsonDump :
294
- file_name_json = "output /" + self .target + "_comment_data.json"
294
+ file_name_json = output_dir + " /" + self .target + "_comment_data.json"
295
295
with open (file_name_json , 'w' ) as f :
296
296
f .write ("{ \" Comments\" :[ \n " )
297
297
f .write ('\n ' .join (json .dumps (comment ) for comment in _comments ) + ',\n ' )
@@ -351,14 +351,14 @@ def get_followers(self):
351
351
followings_list .append (follow )
352
352
353
353
if self .writeFile :
354
- file_name = "output /" + self .target + "_followers.txt"
354
+ file_name = output_dir + " /" + self .target + "_followers.txt"
355
355
file = open (file_name , "w" )
356
356
file .write (str (t ))
357
357
file .close ()
358
358
359
359
if self .jsonDump :
360
360
json_data ['followers' ] = followers
361
- json_file_name = "output /" + self .target + "_followers.json"
361
+ json_file_name = output_dir + " /" + self .target + "_followers.json"
362
362
with open (json_file_name , 'w' ) as f :
363
363
json .dump (json_data , f )
364
364
@@ -416,14 +416,14 @@ def get_followings(self):
416
416
followings_list .append (follow )
417
417
418
418
if self .writeFile :
419
- file_name = "output /" + self .target + "_followings.txt"
419
+ file_name = output_dir + " /" + self .target + "_followings.txt"
420
420
file = open (file_name , "w" )
421
421
file .write (str (t ))
422
422
file .close ()
423
423
424
424
if self .jsonDump :
425
425
json_data ['followings' ] = followings_list
426
- json_file_name = "output /" + self .target + "_followings.json"
426
+ json_file_name = output_dir + " /" + self .target + "_followings.json"
427
427
with open (json_file_name , 'w' ) as f :
428
428
json .dump (json_data , f )
429
429
@@ -472,7 +472,7 @@ def get_hashtags(self):
472
472
hashtags_list = []
473
473
474
474
if self .writeFile :
475
- file_name = "output /" + self .target + "_hashtags.txt"
475
+ file_name = output_dir + " /" + self .target + "_hashtags.txt"
476
476
file = open (file_name , "w" )
477
477
478
478
for k , v in ssort :
@@ -488,7 +488,7 @@ def get_hashtags(self):
488
488
489
489
if self .jsonDump :
490
490
json_data ['hashtags' ] = hashtags_list
491
- json_file_name = "output /" + self .target + "_hashtags.json"
491
+ json_file_name = output_dir + " /" + self .target + "_hashtags.json"
492
492
with open (json_file_name , 'w' ) as f :
493
493
json .dump (json_data , f )
494
494
else :
@@ -564,7 +564,7 @@ def get_user_info(self):
564
564
if 'contact_phone_number' in data and data ['contact_phone_number' ]:
565
565
user ['contact_phone_number' ] = data ['contact_phone_number' ]
566
566
567
- json_file_name = "output /" + self .target + "_info.json"
567
+ json_file_name = output_dir + " /" + self .target + "_info.json"
568
568
with open (json_file_name , 'w' ) as f :
569
569
json .dump (user , f )
570
570
@@ -590,7 +590,7 @@ def get_total_likes(self):
590
590
posts += 1
591
591
592
592
if self .writeFile :
593
- file_name = "output /" + self .target + "_likes.txt"
593
+ file_name = output_dir + " /" + self .target + "_likes.txt"
594
594
file = open (file_name , "w" )
595
595
file .write (str (like_counter ) + " likes in " + str (like_counter ) + " posts\n " )
596
596
file .close ()
@@ -600,7 +600,7 @@ def get_total_likes(self):
600
600
'like_counter' : like_counter ,
601
601
'posts' : like_counter
602
602
}
603
- json_file_name = "output /" + self .target + "_likes.json"
603
+ json_file_name = output_dir + " /" + self .target + "_likes.json"
604
604
with open (json_file_name , 'w' ) as f :
605
605
json .dump (json_data , f )
606
606
@@ -635,7 +635,7 @@ def get_media_type(self):
635
635
if counter > 0 :
636
636
637
637
if self .writeFile :
638
- file_name = "output /" + self .target + "_mediatype.txt"
638
+ file_name = output_dir + " /" + self .target + "_mediatype.txt"
639
639
file = open (file_name , "w" )
640
640
file .write (str (photo_counter ) + " photos and " + str (video_counter ) + " video posted by target\n " )
641
641
file .close ()
@@ -648,7 +648,7 @@ def get_media_type(self):
648
648
"photos" : photo_counter ,
649
649
"videos" : video_counter
650
650
}
651
- json_file_name = "output /" + self .target + "_mediatype.json"
651
+ json_file_name = output_dir + " /" + self .target + "_mediatype.json"
652
652
with open (json_file_name , 'w' ) as f :
653
653
json .dump (json_data , f )
654
654
@@ -700,14 +700,14 @@ def get_people_who_commented(self):
700
700
print (t )
701
701
702
702
if self .writeFile :
703
- file_name = "output /" + self .target + "_users_who_commented.txt"
703
+ file_name = output_dir + " /" + self .target + "_users_who_commented.txt"
704
704
file = open (file_name , "w" )
705
705
file .write (str (t ))
706
706
file .close ()
707
707
708
708
if self .jsonDump :
709
709
json_data ['users_who_commented' ] = ssort
710
- json_file_name = "output /" + self .target + "_users_who_commented.json"
710
+ json_file_name = output_dir + " /" + self .target + "_users_who_commented.json"
711
711
with open (json_file_name , 'w' ) as f :
712
712
json .dump (json_data , f )
713
713
else :
@@ -768,14 +768,14 @@ def get_people_who_tagged(self):
768
768
print (t )
769
769
770
770
if self .writeFile :
771
- file_name = "output /" + self .target + "_users_who_tagged.txt"
771
+ file_name = output_dir + " /" + self .target + "_users_who_tagged.txt"
772
772
file = open (file_name , "w" )
773
773
file .write (str (t ))
774
774
file .close ()
775
775
776
776
if self .jsonDump :
777
777
json_data ['users_who_tagged' ] = ssort
778
- json_file_name = "output /" + self .target + "_users_who_tagged.json"
778
+ json_file_name = output_dir + " /" + self .target + "_users_who_tagged.json"
779
779
with open (json_file_name , 'w' ) as f :
780
780
json .dump (json_data , f )
781
781
else :
@@ -816,14 +816,14 @@ def get_photo_description(self):
816
816
count += 1
817
817
818
818
if self .writeFile :
819
- file_name = "output /" + self .target + "_photodes.txt"
819
+ file_name = output_dir + " /" + self .target + "_photodes.txt"
820
820
file = open (file_name , "w" )
821
821
file .write (str (t ))
822
822
file .close ()
823
823
824
824
if self .jsonDump :
825
825
json_data ['descriptions' ] = descriptions_list
826
- json_file_name = "output /" + self .target + "_descriptions.json"
826
+ json_file_name = output_dir + " /" + self .target + "_descriptions.json"
827
827
with open (json_file_name , 'w' ) as f :
828
828
json .dump (json_data , f )
829
829
@@ -869,7 +869,7 @@ def get_user_photo(self):
869
869
counter = counter + 1
870
870
url = item ["image_versions2" ]["candidates" ][0 ]["url" ]
871
871
photo_id = item ["id" ]
872
- end = "output /" + self .target + "_" + photo_id + ".jpg"
872
+ end = output_dir + " /" + self .target + "_" + photo_id + ".jpg"
873
873
urllib .request .urlretrieve (url , end )
874
874
sys .stdout .write ("\r Downloaded %i" % counter )
875
875
sys .stdout .flush ()
@@ -881,7 +881,7 @@ def get_user_photo(self):
881
881
counter = counter + 1
882
882
url = i ["image_versions2" ]["candidates" ][0 ]["url" ]
883
883
photo_id = i ["id" ]
884
- end = "output /" + self .target + "_" + photo_id + ".jpg"
884
+ end = output_dir + " /" + self .target + "_" + photo_id + ".jpg"
885
885
urllib .request .urlretrieve (url , end )
886
886
sys .stdout .write ("\r Downloaded %i" % counter )
887
887
sys .stdout .flush ()
@@ -913,7 +913,7 @@ def get_user_propic(self):
913
913
URL = data ["hd_profile_pic_versions" ][items - 1 ]['url' ]
914
914
915
915
if URL != "" :
916
- end = "output /" + self .target + "_propic.jpg"
916
+ end = output_dir + " /" + self .target + "_propic.jpg"
917
917
urllib .request .urlretrieve (URL , end )
918
918
pc .printout ("Target propic saved in output folder\n " , pc .GREEN )
919
919
@@ -942,12 +942,12 @@ def get_user_stories(self):
942
942
story_id = i ["id" ]
943
943
if i ["media_type" ] == 1 : # it's a photo
944
944
url = i ['image_versions2' ]['candidates' ][0 ]['url' ]
945
- end = "output /" + self .target + "_" + story_id + ".jpg"
945
+ end = output_dir + " /" + self .target + "_" + story_id + ".jpg"
946
946
urllib .request .urlretrieve (url , end )
947
947
948
948
elif i ["media_type" ] == 2 : # it's a gif or video
949
949
url = i ['video_versions' ][0 ]['url' ]
950
- end = "output /" + self .target + "_" + story_id + ".mp4"
950
+ end = output_dir + " /" + self .target + "_" + story_id + ".mp4"
951
951
urllib .request .urlretrieve (url , end )
952
952
953
953
if counter > 0 :
@@ -1013,14 +1013,14 @@ def get_people_tagged_by_user(self):
1013
1013
tagged_list .append (tag )
1014
1014
1015
1015
if self .writeFile :
1016
- file_name = "output /" + self .target + "_tagged.txt"
1016
+ file_name = output_dir + " /" + self .target + "_tagged.txt"
1017
1017
file = open (file_name , "w" )
1018
1018
file .write (str (t ))
1019
1019
file .close ()
1020
1020
1021
1021
if self .jsonDump :
1022
1022
json_data ['tagged' ] = tagged_list
1023
- json_file_name = "output /" + self .target + "_tagged.json"
1023
+ json_file_name = output_dir + " /" + self .target + "_tagged.json"
1024
1024
with open (json_file_name , 'w' ) as f :
1025
1025
json .dump (json_data , f )
1026
1026
@@ -1032,7 +1032,7 @@ def get_user(self, username):
1032
1032
try :
1033
1033
content = self .api .username_info (username )
1034
1034
if self .writeFile :
1035
- file_name = "output /" + self .target + "_user_id.txt"
1035
+ file_name = output_dir + " /" + self .target + "_user_id.txt"
1036
1036
file = open (file_name , "w" )
1037
1037
file .write (str (content ['user' ]['pk' ]))
1038
1038
file .close ()
@@ -1219,14 +1219,14 @@ def get_fwersemail(self):
1219
1219
t .add_row ([str (node ['id' ]), node ['username' ], node ['full_name' ], node ['email' ]])
1220
1220
1221
1221
if self .writeFile :
1222
- file_name = "output /" + self .target + "_fwersemail.txt"
1222
+ file_name = output_dir + " /" + self .target + "_fwersemail.txt"
1223
1223
file = open (file_name , "w" )
1224
1224
file .write (str (t ))
1225
1225
file .close ()
1226
1226
1227
1227
if self .jsonDump :
1228
1228
json_data ['followers_email' ] = results
1229
- json_file_name = "output /" + self .target + "_fwersemail.json"
1229
+ json_file_name = output_dir + " /" + self .target + "_fwersemail.json"
1230
1230
with open (json_file_name , 'w' ) as f :
1231
1231
json .dump (json_data , f )
1232
1232
@@ -1300,14 +1300,14 @@ def get_fwingsemail(self):
1300
1300
t .add_row ([str (node ['id' ]), node ['username' ], node ['full_name' ], node ['email' ]])
1301
1301
1302
1302
if self .writeFile :
1303
- file_name = "output /" + self .target + "_fwingsemail.txt"
1303
+ file_name = output_dir + " /" + self .target + "_fwingsemail.txt"
1304
1304
file = open (file_name , "w" )
1305
1305
file .write (str (t ))
1306
1306
file .close ()
1307
1307
1308
1308
if self .jsonDump :
1309
1309
json_data ['followings_email' ] = results
1310
- json_file_name = "output /" + self .target + "_fwingsemail.json"
1310
+ json_file_name = output_dir + " /" + self .target + "_fwingsemail.json"
1311
1311
with open (json_file_name , 'w' ) as f :
1312
1312
json .dump (json_data , f )
1313
1313
@@ -1381,14 +1381,14 @@ def get_fwingsnumber(self):
1381
1381
t .add_row ([str (node ['id' ]), node ['username' ], node ['full_name' ], node ['contact_phone_number' ]])
1382
1382
1383
1383
if self .writeFile :
1384
- file_name = "output /" + self .target + "_fwingsnumber.txt"
1384
+ file_name = output_dir + " /" + self .target + "_fwingsnumber.txt"
1385
1385
file = open (file_name , "w" )
1386
1386
file .write (str (t ))
1387
1387
file .close ()
1388
1388
1389
1389
if self .jsonDump :
1390
1390
json_data ['followings_phone_numbers' ] = results
1391
- json_file_name = "output /" + self .target + "_fwingsnumber.json"
1391
+ json_file_name = output_dir + " /" + self .target + "_fwingsnumber.json"
1392
1392
with open (json_file_name , 'w' ) as f :
1393
1393
json .dump (json_data , f )
1394
1394
@@ -1463,14 +1463,14 @@ def get_fwersnumber(self):
1463
1463
t .add_row ([str (node ['id' ]), node ['username' ], node ['full_name' ], node ['contact_phone_number' ]])
1464
1464
1465
1465
if self .writeFile :
1466
- file_name = "output /" + self .target + "_fwersnumber.txt"
1466
+ file_name = output_dir + " /" + self .target + "_fwersnumber.txt"
1467
1467
file = open (file_name , "w" )
1468
1468
file .write (str (t ))
1469
1469
file .close ()
1470
1470
1471
1471
if self .jsonDump :
1472
1472
json_data ['followings_phone_numbers' ] = results
1473
- json_file_name = "output /" + self .target + "_fwerssnumber.json"
1473
+ json_file_name = output_dir + " /" + self .target + "_fwerssnumber.json"
1474
1474
with open (json_file_name , 'w' ) as f :
1475
1475
json .dump (json_data , f )
1476
1476
@@ -1525,14 +1525,14 @@ def get_comments(self):
1525
1525
print (t )
1526
1526
1527
1527
if self .writeFile :
1528
- file_name = "output /" + self .target + "_users_who_commented.txt"
1528
+ file_name = output_dir + " /" + self .target + "_users_who_commented.txt"
1529
1529
file = open (file_name , "w" )
1530
1530
file .write (str (t ))
1531
1531
file .close ()
1532
1532
1533
1533
if self .jsonDump :
1534
1534
json_data ['users_who_commented' ] = ssort
1535
- json_file_name = "output /" + self .target + "_users_who_commented.json"
1535
+ json_file_name = output_dir + " /" + self .target + "_users_who_commented.json"
1536
1536
with open (json_file_name , 'w' ) as f :
1537
1537
json .dump (json_data , f )
1538
1538
else :
0 commit comments