3
3
35000sobak2020-07-04 17:13:01
Python
35000sobak, 2020-07-04 17:13:01

How to get non-broken link of processed image?

There is a python code like this

headers = {'Connection':'keep-alive',
           'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
           'Accept-Encoding':'gzip,deflate',
           'Accept-Language':'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7',
           'Connection':'keep-alive',
           'Access-Control-Allow-Origin': '*',
           'Host':'color.photofuneditor.com',
           'Upgrade-Insecure-Requests': '0',
           'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
        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")
        encoded_image = 'data:image/jpeg;base64,{}'.format(image_hash)
        payload = {'fileToUpload': encoded_image}

        r = requests.post('http://color.photofuneditor.com/ceremony', data=payload, headers=headers)
        if r.status_code == 200:
            jv = "string: {}".format(r.json()['file_link'])
            print(jv)
            image_url = 'http://color.photofuneditor.com/output/{}'.format(r.json()['file_link'])
            r = requests.get(image_url, headers=headers)
            
            with open(str(user_id) + '.jpg', 'wb') as f:
                f.write(r.content)
                
            bot.send_message(message.chat.id, "Вот ваше фото с обработкой:")
            photo = open(str(user_id) + '.jpg', "rb")
            bot.send_photo(message.chat.id, photo)
            os.remove(str(user_id) + '.jpg')


After executing the code, an image arrives with the text that actions with images should be performed on the site, supposedly the script is fired. Although if you process the image through the site and then parse the link, then a full-fledged image is downloaded. I need some way to send an image there (to a form on the site) so that the site sees that I'm doing it through the browser. I know that you can use selenium, as I was already advised here, but this is not suitable. I also tried to work with fake_useragent and sessions, but this did not work. Is there anyway to defeat this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question