Last active
March 24, 2021 17:47
-
-
Save Mnsrff/7265c78a28f6039809906683246ce394 to your computer and use it in GitHub Desktop.
Test
This file contains 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 | |
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