DEV Community

Web Obsidians
Web Obsidians

Posted on

How to Scrape Public Telegram Channels Without the Telegram API (Python and No-Code)

The official way to read Telegram programmatically is the MTProto API (Telethon, Pyrogram), which needs an api_id, a phone number and a logged-in session. For public channels there is a much lighter path: Telegram serves a web preview of every public channel at https://t.me/s/<channel>, and anyone can open it without an account.

Option 1: the t.me/s preview in Python

Each preview page holds the 20 newest posts. Every post carries its id, text, view count and date in the HTML, so BeautifulSoup is enough.

import urllib.request
from bs4 import BeautifulSoup


def views_to_int(s):
    s = s.strip().upper()
    mult = {"K": 1_000, "M": 1_000_000}.get(s[-1:], 1)
    return int(float(s.rstrip("KM")) * mult)


def channel_posts(channel, before=None):
    url = f"https://t.me/s/{channel}" + (f"?before={before}" if before else "")
    req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (channel-reader-script)"})
    html = urllib.request.urlopen(req).read()
    soup = BeautifulSoup(html, "html.parser")
    posts = []
    for msg in soup.select(".tgme_widget_message[data-post]"):
        text = msg.select_one(".tgme_widget_message_text")
        views = msg.select_one(".tgme_widget_message_views")
        when = msg.select_one("time[datetime]")
        posts.append({
            "id": int(msg["data-post"].split("/")[-1]),
            "date": when["datetime"] if when else None,
            "views": views_to_int(views.text) if views else None,
            "text": text.get_text(" ", strip=True) if text else "",
        })
    return posts


page = channel_posts("durov")
for p in page[-3:]:
    print(p["date"], p["views"], p["text"][:60])
older = channel_posts("durov", before=min(p["id"] for p in page))  # the next 20, going back in time
print(len(page), "+", len(older), "posts")
Enter fullscreen mode Exit fullscreen mode

Things you will run into when you go further:

  • Paging works with ?before=<post id>, 20 posts at a time, newest first.
  • Search inside a channel works with ?q=<words> on the same page.
  • Views are rounded in the preview (3.8M), so treat them as approximate.
  • Only public channels with the web preview enabled appear; private groups and chats never do.
  • More fields means more parsing: reactions, forwarded-from, replies, polls, photos, videos and link previews each have their own markup.
  • Be gentle. Telegram answers too many quick requests with 429, so pause between pages and back off on errors.

Option 2: a ready-made Actor with search and monitoring

I packaged that work as an Apify Actor: Telegram Channel Scraper. You paste channel names or links and get one clean row per post. A real item from a run (text and links shortened):

{
  "channel": "telegram",
  "channelTitle": "Telegram News",
  "channelSubscribers": 9090000,
  "postId": 460,
  "url": "https://t.me/telegram/460",
  "date": "2026-08-26T19:12:34Z",
  "text": "For all the info from today's update and a look back at 13 years of Telegram features ...",
  "views": 2640000,
  "reactionsTotal": 0,
  "forwardedFrom": null,
  "edited": false,
  "links": ["https://telegram.org/blog/welcome-messages-buttons-TG-13", "..."],
  "media": [{ "type": "link_preview", "url": "https://telegram.org/blog/welcome-messages-buttons-TG-13" }]
}
Enter fullscreen mode Exit fullscreen mode

What it adds:

  • Reactions, forwards, replies, hashtags, links and media links in one format
  • Search inside a channel and a date range (dateFrom, dateTo)
  • Return only new posts: schedule it hourly and each run returns only the posts that appeared since the last run
  • Export to JSON, CSV or Excel, or send new posts to Slack, Google Sheets or a webhook

From code:

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("webobsidians/telegram-channel-scraper").call(
    run_input={"channels": ["durov", "telegram"], "maxPostsPerChannel": 50, "dateFrom": "2026-11-01"}
)
for post in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(post["channel"], post["date"], post["views"], post["url"])
Enter fullscreen mode Exit fullscreen mode

It costs $1.00 per 1,000 posts plus $0.00005 per run start, with platform usage included, and Apify's free plan includes monthly credit to try it.

Which one should you use?

  • A quick look at one public channel: the Python script.
  • Many channels, keyword search, history by date, or hourly alerts: the Actor.

Either way, you are reading what channel owners publish for everyone, so keep request rates polite.

Top comments (0)