How to Scrape Everything from Telegram Using Python
Telegram is one of the best communications apps around the world. People usually use Telegram for managing their communities and promotions.
In this tutorial, you will learn;
- How to get Api keys for Telegram
- How to extract Group members.
- How to Scrape Telegram Group or Channel Comments
How to get Api keys for Telegram
Let’s get the your telegram api_id and api_hash values. Go to my.telegram.org you will see this are:

Log in here to manage your apps using Telegram API or delete your account. Enter your number and we will send you a confirmation code via Telegram (not SMS).
After login, you will see this picture:

Click on API development tools and fill the required fields. You can choose any name for your app. For example I choosed demo1. After submitting, you will receive App api_id and api_hash like on the picture.

Please save your api_id and api_hash values to somewhere. You will use these api_id and api_hash to login to Telegram API.
How to extract Group members
Telethon is an asyncio Python 3 MTProto library to interact with Telegram’s API as a user or through a bot account. This library is meant to make it easy for you to write Python programs that can interact with Telegram. Think of it as a wrapper that has already done the heavy job for you, so you can focus on developing an application.
Let’s install telethon and pandas using pip:
pip install telethon
pip install pandasLet’s create requirements.txt file
pip freeze > requirements.txt
numpy==1.23.1
pandas==1.4.3
pyaes==1.6.1
pyasn1==0.4.8
python-dateutil==2.8.2
pytz==2022.1
rsa==4.9
six==1.16.0
Telethon==1.24.0After installing telethon and pandas library. Here is the all code to get users information from group and put them in a csv file. Not: You have to past your api_id, api_hash, phone and username.











