I can’t get markup of any site using a bot
there is a bot that in the greeting requests the url of the site from which it will pull the html markup
but when entering the URL throws an exception I would like to note that in the conditional construction! = "": it should be so, because the bot has not been done yet and I send only the url
import requests
token = "????"
bot = telebot.TeleBot(token)
@bot.message_handler(commands=["start"])
def start_messgin(message):
bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЯ - <b>{1.first_name}</b>, бот парсер!Чтобы начать отправь ссылку на сайт".format(message.from_user, bot.get_me()),
parse_mode="html")
@bot.message_handler(content_types=["text"])
def mes(message):
if message.chat.type == "private":
if message.text != "":
res = requests.get(message.text).text
bot.send_message(message.chat.id, res)
bot.polling(none_stop=True)
Ошибка:
ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:
[b'{"ok":false,"error_code":400,"description":"Bad Request: message is too long"}']"
Ответы (1 шт):
Автор решения: Nappy Says
→ Ссылка
Я не могу получить разметку любого сайта с помощью бота
Есть бот, который в приветствии запрашивает URL сайта, с которого он будет тянуть HTML-разметку
Но при вводе URL выдает исключение, хотелось бы отметить, что в условной конструкции! = "": так и должно быть, потому что бот еще не готов, и я отправляю только URL