Scrape the full message history of any Telegram group or channel. Downloads messages, photos, files, and extracts all links into a clean markdown archive.
-
Get Telegram API credentials at my.telegram.org/apps
- Log in with your phone number
- Create an app (name doesn't matter)
- Copy the
api_idandapi_hash
-
Install dependencies
pip install -r requirements.txt
-
Configure credentials
cp .env.example .env # Edit .env with your api_id and api_hash -
First run -- you'll be prompted to log in with your phone number + code. This creates a
session.sessionfile so you only need to do this once.
# Interactive group picker (lists all your groups)
python scrape.py
# Scrape a specific group by name
python scrape.py "My Group Name"
# Text only, skip media downloads (much faster)
python scrape.py "My Group Name" --no-media
# Custom output directory
python scrape.py "My Group Name" -o ./my-export
# Limit to most recent N messages
python scrape.py "My Group Name" --limit 1000Everything goes into output/<group-slug>/:
output/my-group-name/
messages.md -- full message archive, organized by date
links.md -- every URL extracted, with sender + context
photos/ -- all photos (named by date + message ID)
files/ -- all documents, PDFs, videos, etc.
- Full history scrape (all messages from day one)
- Auto-reconnect and retry on failures
- Resume support (skips already-downloaded media)
- Rate limit handling (respects Telegram's FloodWait)
- Sender name resolution with caching
- Link extraction from both message text and web previews
- Clean markdown output, easy to search/read