Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bing Image Search - API issue #587

Open
DariaSka opened this issue Jun 1, 2023 · 1 comment
Open

Bing Image Search - API issue #587

DariaSka opened this issue Jun 1, 2023 · 1 comment

Comments

@DariaSka
Copy link

DariaSka commented Jun 1, 2023

Hi! I am trying to set up my Azure account to use Bing Search API. I have already created a Bing Search v7 resource, a Bing Custom Search resource and even a Bing Cognitive Search resource, though API keys from every one of those return the same error:

HTTPError: 401 Client Error: PermissionDenied for url: https://api.bing.microsoft.com/v7.0/images/search?q=khachapuri&count=150&min_height=128&min_width=128

How do I run this example?

UPD. This code works on my local machine, but not from within the Kaggle notebook. It's basically the same:

def search_images_bing(key, term, min_sz=128, max_images=150):
    search_url = "https://api.bing.microsoft.com/v7.0/images/search"
    headers = {"Ocp-Apim-Subscription-Key" : key}

    params  = {"q": term, "license": "public", "imageType": "photo", "count": max_images, "min_height":min_sz, "min_width":min_sz}
    response = requests.get(search_url, headers=headers, params=params)
    response.raise_for_status()
    return (response.json()['value'])
@DarshitSolanki04
Copy link
Contributor

DarshitSolanki04 commented Oct 7, 2023

Hi @jph00,

Since I was using bing API key, I tried to correct the function 'search_images_bing()' and was able to fix it. If it's alright then I can create a PR for the corrected function. Please let me know.

Thanks,
D

This was referenced Oct 8, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants