File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 44# You may need the below as well
55#pip install pipenv
66#pipenv install requests
7-
7+ # <importsAndVars>
88import json
99import 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
1214subscriptionKey = 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"
1417searchTerm = "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
1822r = requests .get (url , headers = {'Ocp-Apim-Subscription-Key' : subscriptionKey })
1923print (r .text )
24+ # </request>
You can’t perform that action at this time.
0 commit comments