Skip to content

Commit

Permalink
adding new Bing Image Search quickstart sample (Azure-Samples#16)
Browse files Browse the repository at this point in the history
* adding new Bing Image Search quickstart sample

* updating sample
  • Loading branch information
aahill authored and lmazuel committed Sep 10, 2018
1 parent 3d33117 commit 249bbf7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions samples/search/image-search-quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from azure.cognitiveservices.search.imagesearch import ImageSearchAPI
from msrest.authentication import CognitiveServicesCredentials

subscription_key = "Enter your key here"
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 = ImageSearchAPI(CognitiveServicesCredentials(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!")

0 comments on commit 249bbf7

Please sign in to comment.