Last active
December 9, 2024 19:35
-
-
Save liyanasahir/1411b833d0dcfbf7f5533aa058c3bbfa to your computer and use it in GitHub Desktop.
Extracting subscribers list of a Telegram Channel
This file contains hidden or 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
from telethon import TelegramClient, sync | |
# Use your own values here | |
api_id = '123456' | |
api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
channel = 'channel_name' | |
client = TelegramClient('Session_details', api_id, api_hash) | |
phone_number='9199999999' | |
client.connect() | |
print("Connected") | |
if not client.is_user_authorized(): | |
client.send_code_request(phone_number) | |
me = client.sign_in(phone_number, input('Enter code: ')) | |
# get all the users and print them | |
for u in client.iter_participants(channel, aggressive=True): | |
print(u.id, u.first_name) | |
client.disconnect() | |
print("Disconnected") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment