This solves the Permission Denied error by building on Zmey56’s solution.
I created a local instance of the bing search function, that returns an L object.
def search_images_bing(key, term, max_images: int = 100, **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'])
But because the old code looks for the keyname content_url, you need to change it to ‘contentUrl’
results = search_images_bing(key, 'grizzly bear', min_sz=128)
ims = results.attrgot('contentUrl')
Then it works fine and fits in nicely into the jupyter workbooks