Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'} s = requests.Session() s.get('http://color.photofuneditor.com', headers=headers) link_img[user_id] = src with open(link_img[user_id], "rb") as image_file: image_hash = base64.b64encode(image_file.read()).decode("utf-8") FILTER[user_id] = str(FILTER[user_id]) encoded_image = 'data:image/jpeg;base64,{}'.format(image_hash) payload = {'fileToUpload': encoded_image} r = s.post(FILTER[user_id], data=payload, headers=headers) bot.send_message(message.chat.id, "Ждем обработки фото.. 7 секунд") time.sleep(7) if r.status_code == 200: image_url = 'http://color.photofuneditor.com/output/{}'.format(r.json()['file_link']) r = s.get(image_url, headers=headers)
files = {'fileToUpload': (link_img[user_id], open(link_img[user_id], 'rb'))}