Getting more than 10 results by Google Custom Search API V1 in Java

前端 未结 2 404
终归单人心
终归单人心 2021-02-05 10:10

I am using Google Custom Search API in Java to get results of Google in response to a query. I have written this code with the help of other posts, code is as follows:



        
2条回答
  •  独厮守ぢ
    2021-02-05 10:29

    You can't do it that way. num can only be a maximum of 10. See

    https://developers.google.com/custom-search/json-api/v1/reference/cse/list#num

    num - unsigned integer
    Number of search results to return. Valid values are integers between 1 and 10, inclusive.

    To show more results, Google suggests making multiple calls, incrementing the start parameter as needed:

    https://developers.google.com/custom-search/json-api/v1/reference/cse/list#start

    start - unsigned integer The index of the first result to return. Valid value are integers starting 1 (default) and the second result is 2 and so forth. For example &start=11 gives the second page of results with the default "num" value of 10 results per page. Note: No more than 100 results will ever be returned for any query with JSON API, even if more than 100 documents match the query, so setting (start + num) to more than 100 will produce an error. Note that the maximum value for num is 10.

提交回复
热议问题