Update utils.py (#620)

Microsoft updated 'Bing Image Search API' which created incompatibility with the search_images_bing() function. The issue is now resolved.
This commit is contained in:
Darshit Solanki 2024-07-08 04:26:14 +05:30 committed by GitHub
parent 5701d615d4
commit 9cabecb9a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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'])