[Python] How to get the list of (more than 200) members of a Telegram channel

Discussão em 'Python' iniciado por Stack, Junho 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with Telethon to get the entire (more than 200) member list of a Telegram channel.

    Trying, trying and trying again, I found that this piece of code is perfect to reach my goal, if it were not that it prints only first 200 members.

    from telethon import TelegramClient, sync

    # Use your own values here
    api_id = xxx
    api_hash = 'xxx'
    name = 'xxx'
    channel = 'xxx'

    client = TelegramClient('Lista_Membri2', api_id, api_hash)
    try:
    client.start()
    # get all the channels that I can access
    channels = {d.entity.username: d.entity
    for d in client.get_dialogs()
    if d.is_channel}

    # choose the one that I want list users from
    channel = channels[channel]

    # get all the users and print them
    for u in client.get_participants(channel):
    print(u.id, u.first_name, u.last_name, u.username)

    #fino a qui il codice

    finally:
    client.disconnect()


    Someone has the solution?

    Continue reading...

Compartilhe esta Página