From 9cabecb9a6c55ebba18f992ab183887a348f6417 Mon Sep 17 00:00:00 2001 From: Darshit Solanki Date: Mon, 8 Jul 2024 04:26:14 +0530 Subject: [PATCH] Update utils.py (#620) Microsoft updated 'Bing Image Search API' which created incompatibility with the search_images_bing() function. The issue is now resolved. --- utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 64cc2cf..6d5bf6f 100644 --- a/utils.py +++ b/utils.py @@ -31,12 +31,12 @@ from azure.cognitiveservices.search.imagesearch import ImageSearchClient as api from msrest.authentication import CognitiveServicesCredentials as auth def search_images_bing(key, term, min_sz=128, max_images=150): - params = {'q':term, 'count':max_images, 'min_height':min_sz, 'min_width':min_sz} + params = {'q':term, 'count':max_images, 'minHeight':min_sz, 'minWidth':min_sz, 'imageType':'photo'} headers = {"Ocp-Apim-Subscription-Key":key} search_url = "https://api.bing.microsoft.com/v7.0/images/search" response = requests.get(search_url, headers=headers, params=params) response.raise_for_status() - search_results = response.json() + search_results = response.json() return L(search_results['value'])