Answer the question
In order to leave comments, you need to log in
How to send a photo using a link in a telegram bot to aiogram?
After reading the documentation, I made the following code:
if "тест" in message.text.lower():
test = 'ссылка'
await bot.send_photo(message.chat.id, test)
Task exception was never retrieved
future: <Task finished name='Task-22' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=InvalidHTTPUrlContent('Failed to get http url content')>
Traceback (most recent call last):
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\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\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\артем\Desktop\bot\main1.py", line 259, in text
await bot.send_photo(message.chat.id, ssilka)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\bot.py", line 527, in send_photo
result = await self.request(api.Methods.SEND_PHOTO, payload, files)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\base.py", line 231, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\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\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
exceptions.BadRequest.detect(description)
File "C:\Users\артем\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\utils\exceptions.py", line 140, in detect
raise err(cls.text or description)
aiogram.utils.exceptions.InvalidHTTPUrlContent: Failed to get http url content
Answer the question
In order to leave comments, you need to log in
from aiogram.types import URLInputFile
image = URLInputFile(
"https://www.python.org/static/community_logos/python-powered-h-140x182.png",
filename="python-logo.png"
)
await bot.send_photo(message.chat.id, image )
main - the main program of
say - in this case, consider it just a function that prints three parameters as a sentence
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question