Skip to content

rileyvibecodes/telegram-scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Group Scraper

Scrape the full message history of any Telegram group or channel. Downloads messages, photos, files, and extracts all links into a clean markdown archive.

Setup

  1. 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_id and api_hash
  2. Install dependencies

    pip install -r requirements.txt
  3. Configure credentials

    cp .env.example .env
    # Edit .env with your api_id and api_hash
  4. First run -- you'll be prompted to log in with your phone number + code. This creates a session.session file so you only need to do this once.

Usage

# 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 1000

Output

Everything 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.

Features

  • 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

About

Scrape full history of any Telegram group/channel — messages, photos, files, links

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages