From 137af859308e66218f296ea328e1463c5b232a82 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Feb 2021 15:11:43 +0200 Subject: [PATCH] fixing imports --- samples/sdk/autosuggest_samples.py | 2 +- samples/sdk/custom_image_search_samples.py | 2 +- samples/sdk/custom_search_samples.py | 2 +- samples/sdk/entity_search_samples.py | 2 +- samples/sdk/image-search-quickstart.py | 31 +++++++++++----------- samples/sdk/image_search_samples.py | 2 +- samples/sdk/news_search_samples.py | 2 +- samples/sdk/spellcheck_samples.py | 2 +- samples/sdk/video_search_samples.py | 2 +- samples/sdk/visual_search_samples.py | 2 +- samples/sdk/web_search_samples.py | 2 +- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/samples/sdk/autosuggest_samples.py b/samples/sdk/autosuggest_samples.py index 304929f..a1f864a 100644 --- a/samples/sdk/autosuggest_samples.py +++ b/samples/sdk/autosuggest_samples.py @@ -12,7 +12,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" def autosuggest_lookup(subscription_key): """AutoSuggestLookup. diff --git a/samples/sdk/custom_image_search_samples.py b/samples/sdk/custom_image_search_samples.py index 4177937..191719e 100644 --- a/samples/sdk/custom_image_search_samples.py +++ b/samples/sdk/custom_image_search_samples.py @@ -10,7 +10,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" diff --git a/samples/sdk/custom_search_samples.py b/samples/sdk/custom_search_samples.py index 6dcc1ff..9dffdc2 100644 --- a/samples/sdk/custom_search_samples.py +++ b/samples/sdk/custom_search_samples.py @@ -11,7 +11,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" #SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY'] diff --git a/samples/sdk/entity_search_samples.py b/samples/sdk/entity_search_samples.py index 6e74d3e..95eaa16 100644 --- a/samples/sdk/entity_search_samples.py +++ b/samples/sdk/entity_search_samples.py @@ -13,7 +13,7 @@ sys.path.insert(0, current_dir) #SUBSCRIPTION_KEY = os.environ['BING_ENTITY_SEARCH_SUBSCRIPTION_KEY'] #ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT'] -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" def dominant_entity_lookup(subscription_key): diff --git a/samples/sdk/image-search-quickstart.py b/samples/sdk/image-search-quickstart.py index a97ca41..e2115e6 100644 --- a/samples/sdk/image-search-quickstart.py +++ b/samples/sdk/image-search-quickstart.py @@ -13,7 +13,7 @@ sys.path.insert(0, current_dir) #SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY'] #ENDPOINT = os.environ['BING_ENTITY_SEARCH_ENDPOINT'] -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" search_term = "canadian rockies" @@ -21,18 +21,19 @@ search_term = "canadian rockies" """ This application will search images on the web with the Bing Image Search API and print out first image result. """ -# create the image search client -client = ImageSearchClient(AzureKeyCredential(SUBSCRIPTION_KEY)) -# send a search query to the Bing Image Search API -image_results = client.images.search(query=search_term) -print("Searching the web for images of: {}".format(search_term)) +if SUBSCRIPTION_KEY: + # create the image search client + client = ImageSearchClient(AzureKeyCredential(SUBSCRIPTION_KEY)) + # send a search query to the Bing Image Search API + image_results = client.images.search(query=search_term) + print("Searching the web for images of: {}".format(search_term)) -# Image results -if image_results.value: - first_image_result = image_results.value[0] - print("Total number of images returned: {}".format(len(image_results.value))) - print("First image thumbnail url: {}".format( - first_image_result.thumbnail_url)) - print("First image content url: {}".format(first_image_result.content_url)) -else: - print("Couldn't find image results!") + # Image results + if image_results.value: + first_image_result = image_results.value[0] + print("Total number of images returned: {}".format(len(image_results.value))) + print("First image thumbnail url: {}".format( + first_image_result.thumbnail_url)) + print("First image content url: {}".format(first_image_result.content_url)) + else: + print("Couldn't find image results!") diff --git a/samples/sdk/image_search_samples.py b/samples/sdk/image_search_samples.py index bed5c37..b54ef36 100644 --- a/samples/sdk/image_search_samples.py +++ b/samples/sdk/image_search_samples.py @@ -12,7 +12,7 @@ sys.path.insert(0, current_dir) #SUBSCRIPTION_KEY = os.environ["BING_IMAGE_SEARCH_SUBSCRIPTION_KEY"] #ENDPOINT = os.environ['BING_IMAGE_SEARCH_ENDPOINT'] -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" def image_search(subscription_key): diff --git a/samples/sdk/news_search_samples.py b/samples/sdk/news_search_samples.py index ee64b3a..248d0c0 100644 --- a/samples/sdk/news_search_samples.py +++ b/samples/sdk/news_search_samples.py @@ -10,7 +10,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" # Add your Bing Search V7 subscription key to your environment variables. diff --git a/samples/sdk/spellcheck_samples.py b/samples/sdk/spellcheck_samples.py index 6e4835d..12d9c4d 100644 --- a/samples/sdk/spellcheck_samples.py +++ b/samples/sdk/spellcheck_samples.py @@ -11,7 +11,7 @@ sys.path.insert(0, current_dir) # Add your Bing Spell Check subscription key to your environment variables. #SUBSCRIPTION_KEY = os.environ['BING_SPELL_CHECK_SUBSCRIPTION_KEY'] -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" def spellcheck(subscription_key): diff --git a/samples/sdk/video_search_samples.py b/samples/sdk/video_search_samples.py index 5fc6fb0..c593370 100644 --- a/samples/sdk/video_search_samples.py +++ b/samples/sdk/video_search_samples.py @@ -11,7 +11,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" diff --git a/samples/sdk/visual_search_samples.py b/samples/sdk/visual_search_samples.py index 215e8d4..c49efcf 100644 --- a/samples/sdk/visual_search_samples.py +++ b/samples/sdk/visual_search_samples.py @@ -18,7 +18,7 @@ sys.path.insert(0, current_dir) # Add your Bing Autosuggest subscription key to your environment variables. ENDPOINT = "https://api.bing.microsoft.com"+ "/v7.0/" -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None # Add your Bing Search V7 subscription key to your environment variables. #SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY'] diff --git a/samples/sdk/web_search_samples.py b/samples/sdk/web_search_samples.py index 8b0ed65..4311b06 100644 --- a/samples/sdk/web_search_samples.py +++ b/samples/sdk/web_search_samples.py @@ -12,7 +12,7 @@ sys.path.insert(0, current_dir) # Add your Bing Search V7 subscription key to your environment variables. #SUBSCRIPTION_KEY = os.environ['BING_SEARCH_V7_SUBSCRIPTION_KEY'] #ENDPOINT = os.environ['BING_SEARCH_V7_ENDPOINT'] -SUBSCRIPTION_KEY = "00000000000000000000000000" +SUBSCRIPTION_KEY = None # Comment this logging mute out, if you want to include logging #logger = logging.getLogger() # get the default logger