import telebot
import requests
from bs4 import BeautifulSoup as b
bot = telebot.TeleBot('мой токен') # Replace with your bot token
URL = "https://region15.ru/"
clear_news = []
def update_news_page():
r = requests.get(URL)
soup = b(r.text, 'html.parser')
news = soup.find_all('div', class_='news-item')
global clear_news
clear_news = [c.text for c in news]
@bot.message_handler(commands=['start']) # Handle the '/start' command
def send_welcome(message):
bot.reply_to(message, 'Добро пожаловать, {}! \nЭто бот новостей Алании. \n команда на новости:/new_news'.format(message.from_user.first_name))
@bot.message_handler(commands=['new_news']) # Handle the '/start' command
def send_news(message):
update_news_page()
for i in range(10):
bot.send_message(message.chat.id, clear_news[i])
bot.polling() # Start the bot