Getting The Bing Image Search key

hi
i had the same issue. Seems Bing changed the json properties (check out the result).
It is not “content_url” but “contentUrl” now:

urls = results.attrgot(‘contentUrl’)

1 Like

Hey all,

I have my API key but whenever I post it and replace the ‘XXX’ with my key I get the following:

Does anyone know what is going wrong? I don’t know where to define os

I fixed it. I didn’t run the stuff in the notebook before it.

1 Like

This worked for me with some tweaking. I think there is an error in the first line of the second code block which should read: from bing_image_downloader import downloader

Here is my light-weight approach that I verified just now to be working. First I followed the guide @thebigtoona posted :+1:

I then added this cell below the one that starts with (key = os ...) to redefine the included function search_bing_images (this is adopted from this quickstart guide) :

def my_search_images_bing(key, search_term):

    search_url = "https://api.bing.microsoft.com/v7.0/images/search"
    headers = {"Ocp-Apim-Subscription-Key" : key}
    min_size = 128

    params  = {"q": search_term,
               "imageType": "photo",
               "minHeight": min_size,
               "minWidth": min_size,
               "count": 150}
    response = requests.get(search_url, headers=headers, params=params)
    response.raise_for_status()
    search_results = response.json()

    return L(search_results['value'])

search_images_bing = my_search_images_bing
search_images_bing

Edit: clarified code
Hope someone might find this useful.

1 Like

thank you so much, it worked :slight_smile:

Hi all,

Resharing this walkthrough tutorial article for everyone’s reference, since there still seems to be issues with the Bing image downloader: https://towardsdatascience.com/classifying-images-of-alcoholic-beverages-with-fast-ai-34c4560b5543

Cheers!

Hey Kenneth - FYI that link requires a paid medium account to view :frowning:

Hey Tim, sharing the friend link here so that the paywall is deactivated: https://towardsdatascience.com/classifying-images-of-alcoholic-beverages-with-fast-ai-34c4560b5543?sk=d0efa0e6b6d214c52b337a0381a4fd3d

Just did this now. I had already signed up for an Azure account, but the link above did not work.

However, I searched “cognitive services” and found the Bing Search v7 in that.

I believe I first clicked “All Resources” and used that search bar.

NOTE: it no longer says API anywhere as it did in the pictures above

1 Like

Thank you. I follow your suggestion, and use Bing Search v7 instead.
I seems that Bing Search Key link has been changed.


In addition, ims = results.attrgot(‘content_url’) should be changed to ims = results.attrgot(‘contentUrl’) to notebook to work
3 Likes

Hi, @czechcheck. SerpApi developer here. I’ve randomly noticed this comment. Thank you for trying our service to get image URLs.

We can offer free search credits for fast.ai students. Just write us a message via a contact form at serpapi.com.

I’ll post a wrapper function like search_images_bing for SerpApi if someone is interested.

2 Likes

It seems everything has changed from how it was back in 2020. Maybe this is useful for someone who is trying to set up Bing Seach API in 2021 (March).

  1. Go over to the Microsoft API website
  2. Click on “try now”
  3. Finish the setup with Azure.
  4. Fill in the details to create the Bing resource. Make sure to create a new “resource group” and click “create”.
  5. Find your key under the section “Keys and Endpoint”
  6. Copy the key, place it in a file and call it when needed.

Cheers,

9 Likes

Man, you saved my life.

Hey Palaash, I have the same issue. Did you resolve it? Can you help me with me it?

I didn’t find a solution to this Bing issue, but found a great alternative that I use now. Try this!

1 Like

Appreciate the help man. Thank you!

Thanks a lot dude. Appericate it @thatgeeman

Hey people!
Any updates regarding this? Especially the free api part?

Hi Abhay,
I don’t have a solution to this problem, but found a great (and much more easier to use) alternative

1 Like