Skip to content

Instantly share code, notes, and snippets.

@jacKlinc
Created December 5, 2020 10:57
Show Gist options
  • Save jacKlinc/1eb757852c70ca4611d62331f96d8213 to your computer and use it in GitHub Desktop.
Save jacKlinc/1eb757852c70ca4611d62331f96d8213 to your computer and use it in GitHub Desktop.
Bing Image Search Function
def search_images_bing(key, term, max_images: int = 150, **kwargs):
params = {'q':term, 'count':max_images}
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()
return L(search_results['value'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment