[Python] Where do I paste Instaloader code in order to run it?

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to get a list of who liked and commented on my Instagram posts and compare it to my followers list. This way I can determine who is a ghost follower or not. I've installed python (with pip), Instaloader (after much pain), and now i want to run some example code from their site. "Likes of a Profile / Ghost Followers" I found here... https://instaloader.github.io/codesnippets.html

    My question is, where do I paste this code so I can run it???

    I tried running it in a cmd prompt but that does not work. I tried in the python (py) window and that wont work either. Help!


    L = instaloader.Instaloader()

    USER = "your_account"
    PROFILE = USER

    # Load session previously saved with `instaloader -l USERNAME`:
    L.load_session_from_file(USER)

    profile = instaloader.Profile.from_username(L.context, PROFILE)

    likes = set()
    print("Fetching likes of all posts of profile {}.".format(profile.username))
    for post in profile.get_posts():
    print(post)
    likes = likes | set(post.get_likes())

    print("Fetching followers of profile {}.".format(profile.username))
    followers = set(profile.get_followers())

    ghosts = followers - likes

    print("Storing ghosts into file.")
    with open("inactive-users.txt", 'w') as f:
    for ghost in ghosts:
    print(ghost.username, file=f)

    Continue reading...

Compartilhe esta Página