Bing 自定义搜索获取接下来的 10 个结果 ASP.NET C#

问题描述

我能够连接并设置必应自定义搜索。 我的问题是如何获得以下 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];

    }

解决方法

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

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

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...