Created
March 25, 2021 17:06
-
-
Save jonathanenlared/95b53d9ae0a4688d2d37b1a0af4f4189 to your computer and use it in GitHub Desktop.
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 | |
from instagram_private_api import Client, ClientCompatPatch | |
#Variables | |
user_name = 'USERNAME' | |
password = 'PASSWORD' | |
media_id = 'MEDIA_ID' | |
#You could try with 2535835414398697373 on media_id | |
#Get usernames likers from post | |
def get_the_usernames(user_name, password, media_id): | |
api = Client(user_name, password) | |
a = api.media_likers(media_id) | |
with open("data_file.json", "w") as write_file: | |
json.dump(a, write_file) | |
usernames =[] | |
with open('data_file.json') as json_file: | |
data = json.load(json_file) | |
for person in data['users']: | |
usernames.append([person['username']]) | |
with open("usernames" + "_post_" + str(media_id) + ".txt", 'w+') as f: | |
for items in usernames: | |
f.write('%s\n' %items) | |
print("Usernames saved to file successfully") | |
f.close() | |
get_the_usernames(user_name, password, media_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment