Answer the question
In order to leave comments, you need to log in
How to send the name of the person who pressed the button in the telegram group?
Here is my cut code:
import telebot
import requests
from bs4 import BeautifulSoup
from telebot import types
bot = telebot.TeleBot('KEY')
d = {"some1": "ссылка1",
"some2": "ссылка2", "some3": "ссылка3", "some4":"ссылка4"}
@bot.message_handler(commands=['info'])
def info(message):
full_page = requests.get(d["some4"])
soup = BeautifulSoup(full_page.content, 'html.parser', from_encoding='UTF-8')
convert = soup.findAll("div", {"class": "some_class"})
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('button1', callback_data='some1'),
types.InlineKeyboardButton('button2', callback_data='some2'),
types.InlineKeyboardButton('button3', callback_data='some3'),)
msg = []
for i in convert:
msg.append(i.text)
bot.send_message(message.chat.id, "\n".join(msg), parse_mode='html', reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def button_do(call):
full_page = d[call.data]
site = requests.get(full_page)
soup = BeautifulSoup(site.content, 'html.parser', from_encoding='UTF-8')
convert = soup.findAll("div", {"class": "some_class"})
msg = [] # тут нужно вставить то что я описал ниже
for i in convert:
msg.append(i.text)
bot.send_message(call.message.chat.id, "\n".join(msg), parse_mode='html')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question