Getting The Bing Image Search key

Thanks so much, this was great help for me. :slight_smile:

Has anyone here in the recent week tried to obtain a bing search api key? I registered for the azure platform and tried to follow these screenshot instructions but it seems the layout has changed and I can’t seem to find a page to access the bing api key. Any recommendation or advice?

It is asking about card details, do we surely have to fill that? I’m just a student and I don’t have any to pay for it. And I have only my country card which is a Rupay card and not a master or visa card either. How can I afford the key? Someone out there, please help me out to fix this.

I tried this link and created a new API then:

1 Like

Hello! I wrote a blog post on how to use Google Images API to get similar functionality (should work without a card). Please do check it out and let me know if it works for you :slight_smile:

3 Likes

It worked like a charm
Thanks!

There’s quite a number of replies on using bing-image-downloader and yes it works as well. I do found that the results aren’t very clean, as in lots of results that return aren’t grizzly bears for example. Requires more experimentation to support my claim.

I did through a modified
google_images_download :
pip install git+https://github.com/Joeclinton1/google-images-download.git

next :
from google_images_download import google_images_download #importing the library

response = google_images_download.googleimagesdownload() #class instantiation

arguments = {“keywords”:“titmouse bird,nightingale,sparrow”,“limit”:100,“print_urls”:True} #creating list of arguments

paths = response.download(arguments) #passing the arguments to the function

print(paths) #printing absolute paths of the downloaded images

can anyone suggest how to use this further in 02_production.ipynb ?how to correctly replace instead of
results = search_images_bing(key, f’{o} bear’) ?

This is out of date as of October 2020. This is now the way to set it up:

I think a new article should be written and used as the link on the images section:

3 Likes

Thanks Palaash!

I am not able to find search_images_ddg api on the notebook. Is this api available on the fastbook chapt2 notebook?

Resolved : If people are using the template on paperspace, the fastbook version that is available as part of the template is 0.0.14. The new image search api, search_images_ddg is available in later versions. We need to upgrade the fastbook version. You can print your fastbook version using

import fastbook
fastbook.__version__
0.0.18

The latest version as of 21st Aug is 0.0.18. search_image_ddg is available in this version

Here is an alternative to bing image search using the duck duck go api.

from duckduckgo_images_api import search
import warnings
warnings.filterwarnings('ignore', message='Unverified HTTPS request')
import requests

def ddgo_download_images(search_term = None, dest=None, max_results=None):
    search_results = [r['image'] for r in search(search_term, max_results=max_results)['results']]
    image_output_name = [search_term.replace(' ','_') + '_' + str(idx) + '.jpg' for idx in range(len(search_results))]

    for url, image_name in zip(search_results, image_output_name):
        try:
            # Skipping SSLCertVerificationError
            r = requests.get(url, verify=False)
            with open(dest/image_name, 'wb') as outfile:
                outfile.write(r.content)
        except:
            pass
        
path = Path('penguins')
search_terms = ['emperor penguin', 'king penguin']
if not path.exists():
    path.mkdir()
    for search_term in search_terms:
        dest = (path/search_term)
        dest.mkdir(exist_ok=True)
        ddgo_download_images(search_term=search_term, dest=dest, max_results=10)
3 Likes

just wanted to reply to direct people to a solution that solved the issue at the current time, Sept 18, 2021. I was using the default cognitive search, make sure you follow step #2 provided by PedroSousa and search for bing search v7

cheers

Thank you so much! It worked! :grinning:

Had the same problem, so I made a web scrapper for myself and others with this in mind.

No cards, signups or anything needed. Run the .py file from terminal.

If you don’t have chrome & chrome-driver + selenium, there is a how-to (again, terminal command lines to copy-pasta) on the github page.

thanks! to generate a key to access Bing Image Search following the instructions by PedroSousa worked for me on 19/10/21.

it took me a bit of looking around until I found it, so hopefully that will help someone :grinning_face_with_smiling_eyes:

Wow, this helped me a lot, thank you!

Hi @thatgeeman
Thanks for the google search alternative and the detailed explanation on how to set it up.
However I am getting a '404 Client Error : Not Found for url’
When I tried the url https://googleapis.com/customsearch/v1 it indeed no longer exists and instead I ended up in https://developers.google.com/custom-search/v1

Did you face a similar issue ?

I found a solution to my problem.
In fact the url for search changed and instead of
https://googleapis.com/customsearch/v1
I used
https://customsearch.googleapis.com/customsearch/v1