好的,让我们首先说我是一个 Python 菜鸟。因此,我正在与 Telethon 合作以获取 Telegram 频道的整个(超过 200 个)成员列表。
尝试,尝试再尝试,我发现这段代码非常适合达到我的目标,如果不是它只打印前 200 个成员。
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()
有人有解决方案吗?谢谢!!