Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ChatBot/imageSearch.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21 lines (18 sloc)
805 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example code from image api | |
from azure.cognitiveservices.search.imagesearch import ImageSearchAPI | |
from msrest.authentication import CognitiveServicesCredentials | |
# Add your Bing Search V7 subscription key to your environment variables. | |
subscription_key = '' | |
search_term = input() | |
# 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(format(first_image_result.content_url)) | |
else: | |
print("Couldn't find image results!") | |
# End of example code from image api |