Пользовательский поиск Bing дает следующие 10 результатов ASP.NET C#

Мне удалось подключиться и настроить пользовательский поиск Bing. Мой вопрос: как получить следующие 10 результатов? И возможно ли получить более 10 результатов за один запрос?

          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];

    }

2 ответа

Есть параметр запроса, который по умолчанию равен 10.

Для разбивки на страницы используйте offset, с шагом count

ссылаться на документы - https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/quickstarts/rest/csharp

Добавьте параметр count к URL-адресу https://api.bing.microsoft.com/v7.0/custom/search?q=microsoft&amp;amp;customconfig=***&amp;amp;count=20, и API вернет результаты в соответствии со значением счетчика.

Пожалуйста, обратитесь по адресу https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/reference/query-parameters.

Другие вопросы по тегам