File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 1515
1616# Add your Bing Search V7 subscription key and endpoint to your environment variables.
1717subscriptionKey = os .environ ['BING_SEARCH_V7_SUBSCRIPTION_KEY' ]
18- host = os .environ ['BING_SEARCH_V7_ENDPOINT' ]
19- path = "/bing/v7.0/videos/search"
18+ endpoint = os .environ ['BING_SEARCH_V7_ENDPOINT' ] + "/bing/v7.0/videos/search"
2019
2120# Search query
2221query = "kittens"
2928params = { "q" : query }
3029
3130# Call the API
32- response = requests .get (host + path , headers = headers , params = params )
33- response .raise_for_status ()
34-
35- # Print results
36- print ("\n Headers:\n " )
37- print (response .headers )
38-
39- print ("\n JSON Response:\n " )
40- pprint (response .json ())
31+ try :
32+ response = requests .get (endpoint , headers = headers , params = params )
33+ response .raise_for_status ()
34+
35+ # Print results
36+ print ("\n Headers:\n " )
37+ print (response .headers )
38+
39+ print ("\n JSON Response:\n " )
40+ pprint (response .json ())
41+ except Exception as ex :
42+ raise ex
You can’t perform that action at this time.
0 commit comments