Skip to content

Commit a3fbe66

Browse files
authored
Updated key/endpoint
Endpoints are not region-based anymore, but rather custom domain -based. Although regional endpoints will still work. Also, the authentication information is moving to a standard of getting it from environment variables.
1 parent 0d20f1e commit a3fbe66

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/Search/BingCustomSearchv7.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
import json
99
import requests
1010

11-
subscriptionKey = "YOUR-SUBSCRIPTION-KEY"
11+
# Add your Bing Custom Search subscription key to your environment variables.
12+
subscriptionKey = os.environ['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
1213
customConfigId = "YOUR-CUSTOM-CONFIG-ID"
1314
searchTerm = "microsoft"
1415

15-
url = 'https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search?q=' + searchTerm + '&customconfig=' + customConfigId
16+
# 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
1618
r = requests.get(url, headers={'Ocp-Apim-Subscription-Key': subscriptionKey})
1719
print(r.text)

0 commit comments

Comments
 (0)