I'm already can search images by text-requser, using this python-script:
ap = argparse.ArgumentParser()
ap.add_argument("-q", "--query", required=True, help="search query to search Bing Image API for")
ap.add_argument("-o", "--output", required=True, help="path to output directory of images")
args = vars(ap.parse_args())
API_KEY = "my_api_key_here"
MAX_RESULTS = 250
GROUP_SIZE = 50
URL = "https://api.cognitive.microsoft.com/bing/v7.0/images/search"
EXCEPTIONS = set([IOError, FileNotFoundError, exceptions.RequestException, exceptions.HTTPError, exceptions.ConnectionError, exceptions.Timeout])
term = args["query"]
headers = {"Ocp-Apim-Subscription-Key": API_KEY}
params = {"q": term, "offset": 0, "count": GROUP_SIZE}
search = requests.get(URL, headers=headers, params=params)
search.raise_for_status()
results = search.json()
estNumResults = min(results["totalEstimatedMatches"], MAX_RESULTS)
total = 0
for offset in range(0, estNumResults, GROUP_SIZE):
params["offset"] = offset
search = requests.get(URL, headers=headers, params=params)
search.raise_for_status()
results = search.json()
for v in results["value"]:
try:
r = requests.get(v["contentUrl"], timeout=30)
ext = v["contentUrl"][v["contentUrl"].rfind("."):]
p = os.path.sep.join([args["output"], "{}{}".format(
str(total).zfill(8), ext)])
f = open(p, "wb")
f.write(r.content)
f.close()
image = cv2.imread(p)
if image is None:
print("[INFO] deleting: {}".format(p))
os.remove(p)
continue
total += 1
except Exception as e:
if type(e) in EXCEPTIONS:
continue
But I want to search similar images using image url, just like in Bing search: https://www.bing.com/images/search?view=detailv2&iss=sbi&form=SBIHMP&sbisrc=UrlPaste&q=imgurl:https%3A%2F%2Fimg-fotki.yandex.ru%2Fget%2F4807%2Fgelionsk.da%2F0_4ba5a_82bb84ac_orig&idpbck=1&selectedindex=0&id=https%3A%2F%2Fimg-fotki.yandex.ru%2Fget%2F4807%2Fgelionsk.da%2F0_4ba5a_82bb84ac_orig&mediaurl=https%3A%2F%2Fimg-fotki.yandex.ru%2Fget%2F4807%2Fgelionsk.da%2F0_4ba5a_82bb84ac_orig&exph=0&expw=0&vt=2&sim=1
But I can not find something about it in documentation. Is it possible? If yes, how can I do it?