0

我能够连接和设置 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];

    }
4

2 回答 2

1

有一个count查询参数默认为10

要分页,请使用offset, 增量count

参考文档 - https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/quickstarts/rest/csharp

于 2021-07-30T05:31:47.643 回答
0

将计数参数添加到 URL https://api.bing.microsoft.com/v7.0/custom/search?q=microsoft&customconfig=***&count=20并且 API 根据计数值返回结果。

请参考https://docs.microsoft.com/en-us/bing/search-apis/bing-custom-search/reference/query-parameters

于 2021-08-25T14:26:40.060 回答