Skip to content

Commit bef822a

Browse files
author
Aaron Hill
committed
removing search sample changes
1 parent 0aed91f commit bef822a

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

samples/search/custom_search_samples.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
# <imports>
2-
import os
31
from azure.cognitiveservices.search.customsearch import CustomSearchClient
42
from msrest.authentication import CognitiveServicesCredentials
5-
# </imports>
63

7-
# <vars>
84
SUBSCRIPTION_KEY = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
9-
search_term = "xbox"
10-
custom_config = "your-custom-config-id" # You can also use "1"
11-
# </vars>
12-
13-
# <authentication>
14-
client = CustomSearchClient(CognitiveServicesCredentials(SUBSCRIPTION_KEY))
15-
# </authentication>
16-
17-
"""CustomSearch.
18-
This will look up a single query and print out name and url for first web result.
19-
"""
20-
# <request>
21-
def custom_search_web_page_result_lookup():
5+
6+
7+
def custom_search_web_page_result_lookup(subscription_key):
8+
"""CustomSearch.
9+
10+
This will look up a single query (Xbox) and print out name and url for first web result.
11+
"""
12+
13+
client = CustomSearchClient(CognitiveServicesCredentials(subscription_key))
14+
2215
try:
23-
web_data = client.custom_instance.search(query=search_term, custom_config=1)
24-
print("Searched for Query: " + search_term)
16+
web_data = client.custom_instance.search(query="xbox", custom_config=1)
17+
print("Searched for Query 'xbox'")
2518

2619
if web_data.web_pages.value:
2720
first_web_result = web_data.web_pages.value[0]
@@ -34,7 +27,7 @@ def custom_search_web_page_result_lookup():
3427

3528
except Exception as err:
3629
print("Encountered exception. {}".format(err))
37-
# <request>
30+
3831

3932
if __name__ == "__main__":
4033
import sys

0 commit comments

Comments
 (0)