Skip to content

Commit 22e8370

Browse files
authored
Minor
1 parent 501e39c commit 22e8370

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

python/Search/BingVideoSearchv7.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515

1616
# Add your Bing Search V7 subscription key and endpoint to your environment variables.
1717
subscriptionKey = 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
2221
query = "kittens"
@@ -29,12 +28,15 @@
2928
params = { "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("\nHeaders:\n")
37-
print(response.headers)
38-
39-
print("\nJSON 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("\nHeaders:\n")
37+
print(response.headers)
38+
39+
print("\nJSON Response:\n")
40+
pprint(response.json())
41+
except Exception as ex:
42+
raise ex

0 commit comments

Comments
 (0)