Skip to content

Commit f41dec9

Browse files
committed
updating python sample
1 parent 4ce1930 commit f41dec9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

python/Search/BingCustomSearchv7.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@
44
# You may need the below as well
55
#pip install pipenv
66
#pipenv install requests
7-
7+
# <importsAndVars>
88
import json
99
import requests
10+
import os
1011

1112
# Add your Bing Custom Search subscription key to your environment variables.
13+
# Your endpoint will have the form: https://<your-custom-subdomain>.cognitiveservices.azure.com/bingcustomsearch/v7.0
1214
subscriptionKey = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
13-
customConfigId = "YOUR-CUSTOM-CONFIG-ID"
15+
endpoint = os.environ['BING_CUSTOM_SEARCH_ENDPOINT']
16+
customConfigId = "1" #you can also use "1"
1417
searchTerm = "microsoft"
15-
18+
# </importsAndVars>
19+
# <request>
1620
# Add your Bing Custom Search endpoint to your environment variables.
17-
url = os.environ['BING_CUSTOM_SEARCH_ENDPOINT'] + "/bingcustomsearch/v7.0/search?q=' + searchTerm + '&customconfig=' + customConfigId
21+
url = endpoint + "/search?q=" + searchTerm + "&customconfig=" + customConfigId
1822
r = requests.get(url, headers={'Ocp-Apim-Subscription-Key': subscriptionKey})
1923
print(r.text)
24+
# </request>

0 commit comments

Comments
 (0)