I was able to connect and setup Bing custom search. My question is how to get the following 10 results? And is it possible to get more than 10 results in one request?
var subscriptionKey = "My Key";
var customConfigId = "My ID";
var searchTerm = "test";
var url = "https://api.bing.microsoft.com/v7.0/custom/search?q=" + searchTerm + "&customconfig=" + customConfigId + "&mkt=en-US";
var client = new HttpClient();
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", subscriptionKey);
var httpResponseMessage = client.GetAsync(url).Result;
var responseContent = httpResponseMessage.Content.ReadAsStringAsync().Result;
BingCustomSearchResponse response = JsonConvert.DeserializeObject<BingCustomSearchResponse>(responseContent);
for (int i = 0; i < response.webPages.value.Length; i++)
{
var webPage = response.webPages.value[i];
}
There is a
countquery parameter that defaults to 10To paginate, use
offset, in increments ofcountrefer docs - https://learn.microsoft.com/en-us/bing/search-apis/bing-custom-search/quickstarts/rest/csharp