Reverse search an image in Yandex Images using Python

You can get url with an image search by using this code. Tested on ubuntu 18.04, with python 3.7 and requests 2.23.0

import json

import requests

file_path = "C:\\path\\whateverThisIs.png"
search_url = 'https://yandex.ru/images/search'
files = {'upfile': ('blob', open(file_path, 'rb'), 'image/jpeg')}
params = {'rpt': 'imageview', 'format': 'json', 'request': '{"blocks":[{"block":"b-page_type_search-by-image__link"}]}'}
response = requests.post(search_url, params=params, files=files)
query_string = json.loads(response.content)['blocks'][0]['params']['url']
img_search_url = search_url + '?' + query_string
print(img_search_url)

There are no API for developers. You can try reverse inginer queries from your browser, but you will have to deal with anty robot protect.

Another way to speed up process (but still manual)

  1. As described here https://yandex.com/support/images/loaded-image.html install Yandex.Browser where you have hot key for image search
  2. Host/make your site with all source images foe search queries
  3. Open your site in Yandex.Browser use "right mouse click"+"serch image at yandex"
  4. Copy what you need from page with results