Created
February 15, 2020 22:18
-
-
Save ahmetanbar/f1ba3f9777c68e60cf56c47138558b42 to your computer and use it in GitHub Desktop.
Parsing instagram messages archieve json data for each suspected user and showing chats clearly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
suspectes = [""] # forexample "anbarahmet" | |
json_file = "" # forexample: messages.json | |
with open(json_file, 'r', encoding='utf8', errors='ignore') as f: | |
data = json.load(f) | |
for user in suspectes: | |
for i in data: | |
if user in i['participants'][0] or user in i['participants'][1]: | |
for j in i['conversation']: | |
f = open(user + ".txt", "a", encoding="utf-8") | |
if 'text' in j: | |
if j['text']: | |
print(j['sender'] + " -- " + j['created_at'] + " -- " +j['text']+"\n") | |
f.write(j['sender'] + " -- " + j['created_at'] + " -- " +j['text']+"\n") | |
else: | |
f.write(j['sender'] + " -- "+j['created_at']+ " -- "+ "media that is not text"+"\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment