2013-12-18 37 views
0

我有使用谷歌搜索引擎的Java应用程序。 Customsearch custom = new Customsearch(new NetHttpTransport(),new JacksonFactory(),httpRequestInitializer);Google搜索引擎只返回10个结果

Customsearch.Cse.List list = custom.cse().list("some query"); 
    list.setCx(cx); 
    list.setKey(key); 

    Search result = list.execute(); 
    List<Result> listResult = result.getItems(); 

问题是,listResult.size()= 10。不管多少结果实际上它返回我前10个结果。

请帮我解决这个问题!

回答

1

你没有设定结果的数量,返回和10是默认的,API在这里 - https://developers.google.com/resources/api-libraries/documentation/customsearch/v1/java/latest/

list.setNum(100); 
+1

非常感谢您!根据文档每当我将数字设置为Customsearch.Cse.List列表对象时:例如list.setNumber(100)会出现以下异常: 线程“main”com.google.api.client.googleapis.json中的异常.GoogleJsonResponseException:400错误的请求 { “代码”:400, “错误”:[{ “域”: “全局”, “消息”: “无效值”, “理由”: “无效的” }], “消息”: “无效值” } \t在com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145) 这发生在数为> 10 – user2739823

相关问题