[英]Google Custom Site Search Api C# Paging
I am using the Google C# API for the Custom Search and have it working and returning results, however I cannot see a way to make the paging work correctly. 我正在使用Google C#API进行自定义搜索,并使其正常工作并返回结果,但是我看不到使分页正常工作的方法。
Looking at what I get returned, no where does it tell me how many pages there are in the result? 看看返回的内容,没有什么地方可以告诉我结果中有多少页? It just has a .Start property?
它只是具有.Start属性? Which is not much good unless I know how many 'pages' of results I have?
除非我知道结果有多少“页”,否则哪一个不是很好?
Am I missing something stupid here? 我在这里想念一些愚蠢的东西吗? Here is an example of the code I have so far
这是我到目前为止的代码示例
var svc = new CustomsearchService(new BaseClientService.Initializer { ApiKey = settings.GoogleCustomSearchApi });
var listRequest = svc.Cse.List(searchTerm);
listRequest.Cx = settings.GoogleCustomSearchEngineId;
listRequest.ImgSize = CseResource.ListRequest.ImgSizeEnum.Medium;
listRequest.Num = 10;
// List to hold everything in
var resultItems = new List<Google.Apis.Customsearch.v1.Data.Result>();
// Result set 1
listRequest.Start = 1;
var search = listRequest.Execute();
resultItems.AddRange(search.Items);
I have resulted at the moment to doing two or three calls one after the other and getting a load of results back. 目前,我的结果是一个接一个地进行两个或三个调用,并返回大量结果。 But I would prefer to have this properly paged.
但我希望对此进行正确的分页。
The JSON API response has totlResults field: https://developers.google.com/custom-search/json-api/v1/reference/cse/list#response . JSON API响应具有totlResults字段: https : //developers.google.com/custom-search/json-api/v1/reference/cse/list#response 。 It should be exposed under search.Queries
它应该在搜索下公开。
找到了它
search.SearchInformation.TotalResults
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.