from aiogram import Bot, Dispatcher, executor, types
import requests
from bs4 import BeautifulSoup
import time
import smtplib
API_TOKEN = '5653760842:AAGQrVSXGQkMXpia3Ce9DNp2G60v3v291o8'
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
#class Currency:
EURO_RUB = 'https://www.google.com/search?q=euro+to+ruble&newwindow=1&sxsrf=APwXEde8pFrfqho1nOYcU2NFF-_YaVBCCg%3A1680350839745&ei=dx4oZP_5LLKB9u8P_v-OwAs&ved=0ahUKEwi_kZrX0oj-AhWygP0HHf6_A7gQ4dUDCA8&uact=5&oq=euro+to+ruble&gs_lcp=Cgxnd3Mtd2l6LXNlcnAQAzIMCAAQigUQQxBGEIICMgUIABCABDIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBQgAEIAEMgUIABCABDIFCAAQgAQyBQgAEIAEOgoIABBHENYEELADOgoIABCKBRCwAxBDOgQIIxAnOgoILhDHARDRAxAnOgsILhCABBDHARDRAzoHCAAQigUQQzoHCC4QigUQQzoQCC4QigUQxwEQ0QMQ1AIQQzoHCAAQgAQQCjoKCAAQgAQQFBCHAjoPCAAQgAQQFBCHAhBGEIICSgQIQRgAUIEIWLIeYL4iaAFwAXgAgAH0AYgBrAySAQU1LjcuMZgBAKABAcgBCsABAQ&sclient=gws-wiz-serp'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'}
full_page = requests.get(EURO_RUB, headers=headers)
soup = BeautifulSoup(full_page.content, 'html.parser')
convert = soup.findAll("span", {"class": "DFlfde", "class": "SwHCTb", "data-precision": 2})
print(convert[0].text)
@dp.message_handler(commands=['start'])
async def send_welcome(message: types.Message):
await message.reply("Привет!\nАктуальный курс евро:", {float(convert[0].text.replace(',','.'))*1.05})
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Программка - простой бот в телеграме, который парсит стоимость евро в рублях и отправляет пользователю, предварительно добавив 5 процентов. Выдает следующий трейсбек:
C:\Users\Pavel\PycharmProjects\pythonProject1\venv\Scripts\python.exe C:\Users\Pavel\PycharmProjects\pythonProject1\venv\main.py
84,79
Updates were skipped successfully.
Task exception was never retrieved
future: <Task finished name='Task-9' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=BadRequest('Unsupported parse_mode')>
Traceback (most recent call last):
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\main.py", line 23, in send_welcome
await message.reply("Привет!\nАктуальный курс евро:", {float(convert[0].text.replace(',','.'))*1.05})
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\types\message.py", line 1687, in reply
return await self.bot.send_message(
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\bot\bot.py", line 346, in send_message
result = await self.request(api.Methods.SEND_MESSAGE, payload)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\bot\base.py", line 236, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\bot\api.py", line 140, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "C:\Users\Pavel\PycharmProjects\pythonProject1\venv\lib\site-packages\aiogram\utils\exceptions.py", line 141, in detect
raise cls(description)
aiogram.utils.exceptions.BadRequest: Unsupported parse_mode
Как такое решить?