File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ from azure .cognitiveservices .search .imagesearch import ImageSearchAPI
2+ from msrest .authentication import CognitiveServicesCredentials
3+
4+ subscription_key = "Enter your key here"
5+ search_term = "canadian rockies"
6+
7+ """
8+ This application will search images on the web with the Bing Image Search API and print out first image result.
9+ """
10+ #create the image search client
11+ client = ImageSearchAPI (CognitiveServicesCredentials (subscription_key ))
12+ # send a search query to the Bing Image Search API
13+ image_results = client .images .search (query = search_term )
14+ print ("Searching the web for images of: {}" .format (search_term ))
15+
16+ # Image results
17+ if image_results .value :
18+ first_image_result = image_results .value [0 ]
19+ print ("Total number of images returned: {}" .format (len (image_results .value )))
20+ print ("First image thumbnail url: {}" .format (first_image_result .thumbnail_url ))
21+ print ("First image content url: {}" .format (first_image_result .content_url ))
22+ else :
23+ print ("Couldn't find image results!" )
You can’t perform that action at this time.
0 commit comments