@Sai Kishore Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
.
I was able to use the below python sample code and call the Bing Search endpoint. Could you please test the same and check if that helps ?
.
Please note, update the subscription key
(api-key
) and the query text
accordingly.
.
import requests
subscription_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
search_url = "https://api.bing.microsoft.com/v7.0/search"
headers = {"Ocp-Apim-Subscription-Key": subscription_key}
params = {"q": "
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()
webpages = search_results.get('webPages', {}).get('value', [])
for i, webpage in enumerate(webpages):
name = webpage.get('name')
url = webpage.get('url')
snippet = webpage.get('snippet')
print(f"Result {i+1}:\nTitle: {name}\nURL: {url}\nSnippet: {snippet}\n{'-'*50}")
# If there are no results
if not webpages:
print("No results found.")
.
Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help. . ** Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.