Skip to content

Instantly share code, notes, and snippets.

@Mnsrff
Last active March 24, 2021 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mnsrff/7265c78a28f6039809906683246ce394 to your computer and use it in GitHub Desktop.
Save Mnsrff/7265c78a28f6039809906683246ce394 to your computer and use it in GitHub Desktop.
Test
from telethon import TelegramClient
import pandas as pd
import asyncio
api_id = ...
api_hash = '...'
phone = '+7...'
channel_href = 'https://t.me/...'
async def start():
client = TelegramClient('session_name', api_id, api_hash)
client = await client.start()
dialogs = await client.get_dialogs()
async def then():
channels = {d.entity.username: d.entity
for d in dialogs
if d.is_channel}
my_channel = channel_href.split('/')[-1]
channel = channels[my_channel]
async def get():
members_telethon_list = await client.get_participants(channel, aggressive=True)
async def next():
username_list = [member.username for member in members_telethon_list]
first_name_list = [member.first_name for member in members_telethon_list]
last_name_list = [member.last_name for member in members_telethon_list]
phone_list = [member.phone for member in members_telethon_list]
async def last():
df = pd.DataFrame()
df['username'] = username_list
df['first_name'] = first_name_list
df['last_name'] = last_name_list
df['phone'] = phone_list
df.to_csv('subscribers.csv', index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment