Answer the question
In order to leave comments, you need to log in
Why is the picture not updating in telegram bot?
I'm making a bot to generate random cats. I take the url https://thiscatdoesnotexist.com/ . But the image is not updated. What to do?
if message.text == '!кот':
bot.send_photo(message.chat.id,
f'https://thiscatdoesnotexist.com/', reply_markup=klikeordislike)
Answer the question
In order to leave comments, you need to log in
Most likely telegram caches the request and then uses the photo from the cache. Just upload the file and then send
import requests
r = requests.get('https://thiscatdoesnotexist.com')
with open('image_temp.jpg', 'wb') as f:
f.write(r.content)
bot.send_photo(message.chat.id, open('image_temp.jpg', 'rb'))
import requests
from PIL import Image
import io
r = requests.get('https://thiscatdoesnotexist.com')
bot.send_photo(message.chat.id, Image.open(io.BytesIO(r.content)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question