Formulate your query:
To search for results from a specific domain, use the site:
operator followed by the domain name. For example, if you want to search for "cats" only on the domain "example.com", your query would look like this:
cats site:example.com
Sample Python code is below
import requests
subscription_key = "YOUR_SUBSCRIPTION_KEY"
search_term = "cats site:example.com"
endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search"
headers = {
"Ocp-Apim-Subscription-Key": subscription_key
}
params = {
"q": search_term,
"count": 50, # number of results per request, up to 50
"offset": 0, # index of the first result to return, useful for pagination
"mkt": "en-US" # market to use for the search, for example, "en-US"
}
response = requests.get(endpoint, headers=headers, params=params)
search_results = response.json()
for result in search_results["webPages"]["value"]:
print(result["name"], result["url"])