How to extract data from notcoin Telegram mini app to monitor new mining pools

I’m building an automation script that monitors the notcoin Telegram bot for newly launched pools and sends alerts to my channel. The goal is to automatically detect when fresh pools become available and forward this info to subscribers.

Here’s my current approach:

config.py:

from dotenv import load_dotenv
import asyncio
import logging
import telegram_monitor

load_dotenv()

if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(telegram_monitor.initialize())

telegram_monitor.py:

import asyncio
import aiohttp
from os import environ
from aiogram import Bot, Dispatcher, types
from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode
from aiogram.filters import CommandStart
from aiogram.types import Message
from bs4 import BeautifulSoup

dp = Dispatcher()

notification_suffix = "Don't miss out on this opportunity!"
target_channel = ""
processed_pools = []
scan_frequency = 3600

async def initialize():
    global telegram_bot
    telegram_bot = Bot(
        environ.get("BOT_TOKEN"),
        default=DefaultBotProperties(parse_mode=ParseMode.HTML),
    )
    
    await telegram_bot.delete_webhook(drop_pending_updates=True)
    await dp.start_polling(telegram_bot)

@dp.message(CommandStart())
async def handle_start_command(message: Message):
    await message.answer(f"Welcome! Your user ID: {message.from_user.id}")

async def scrape_pool_information():
    async with aiohttp.ClientSession() as session:
        async with session.get("https://t.me/notcoin_bot") as response:
            parser = BeautifulSoup(await response.text(), "html.parser")
    
    pool_elements = parser.find_all("div", class_="pool")
    for element in pool_elements:
        pool_title = element.find("h3").text
        reward_amount = element.find("span", class_="reward").text
        
        if pool_title not in processed_pools:
            processed_pools.append(pool_title)
            
            message_content = f"**New Pool Alert:** {pool_title} | **Reward Rate:** {reward_amount} per hour.\n{notification_suffix}"
            await telegram_bot.send_message(target_channel, message_content)

async def run_periodic_check(wait_time):
    await asyncio.sleep(wait_time)
    event_loop = asyncio.get_event_loop()
    event_loop.create_task(scrape_pool_information())
    event_loop.create_task(run_periodic_check(scan_frequency))

The bot responds to the start command correctly but the pool monitoring functionality isn’t working. What could be causing this issue with the data extraction logic?

Been there myself with telegram bot automation. Your scrape_pool_information() function never gets called - that’s the issue. You’re only running dp.start_polling(telegram_bot) which waits for messages, but nothing triggers your periodic check.

Add asyncio.create_task(run_periodic_check(scan_frequency)) before polling starts in your initialize function. But honestly, this whole approach won’t work since telegram mini apps are sandboxed. I switched to monitoring official announcement channels instead - way more reliable and you can actually use telegram’s message monitoring instead of trying to scrape protected content.

totally agree! scraping is def not the way to go for telegram bots. use the api to pull messages straight from the channel. it’s way more reliable than scraping. stick to the official methods and you’ll be good!

Your scraping approach won’t work. Telegram mini apps like Notcoin don’t expose data through web scraping - they run inside Telegram’s iframe with authentication barriers and dynamic content loading.

I’ve hit similar walls before. The main issue is https://t.me/notcoin_bot just returns a basic webpage stub, not the actual bot interface. The pool data you want lives inside the mini app’s authenticated session, which needs user interaction and proper API calls.

You’ll need to reverse engineer the mini app’s network requests using browser dev tools or try Telegram’s userbot libraries like Telethon to interact with the bot programmatically. Just heads up - automated interactions might violate the bot’s terms of service. Safer bet would be monitoring official announcement channels if Notcoin posts pool updates there.