我正在使用Google.Apis.Customsearch.v1来定制谷歌搜索。查询需要num
和start
参数用于分页。按照谷歌的文档here为start
和num
查询参数谷歌搜索API抛出错误,有效参数
开始
可选。 start参数表示应该包含在搜索结果中的第一个匹配结果。 start参数使用从零开始的索引,意思是第一个结果是0,第二个结果是1等等。
start参数与num参数一起使用以确定要返回哪些搜索结果。请注意,任何查询都不会返回超过1000个结果,即使超过1000个文档与查询匹配,因此将开始设置为1000或更多时也不会产生结果。
NUM
说明
可选。 num参数标识要返回的搜索结果的数量。默认的num值是10,最大值是20.如果您请求的结果超过20个,则只返回20个结果。
注意:如果搜索结果的总数小于请求的结果数量,则会返回所有可用的搜索结果。
然而,当我设置start
为0,num
20我得到错误
{“Google.Apis.Requests.RequestError \ r \ n无效的值[400] \ r \ n错误[\ r \ n \ tMessage [无效值]地址[ - ]原因[无效]域[全球] \ r \ n] \ r \ n“}
这里是我的代码
CustomsearchService customSearchService =
new CustomsearchService(new Google.Apis.Services.BaseClientService.Initializer() { ApiKey = apiKey });
Google.Apis.Customsearch.v1.CseResource.ListRequest listRequest = customSearchService.Cse.List(query);
listRequest.Cx = searchengineid;
listRequest.Start = 0;
listRequest.Num = 20;
Search search = listRequest.Execute();
我必须将start
设置为1,将num
设置为10才能使其工作。那么,为什么它不工作按文档