GoogleCustom API number of results

一笑奈何 提交于 2019-12-11 03:36:03

问题


How is possible to get more results then 10 with googlecoustom API? I think its just take results from 1st page... when I type to search more then 10 I get this error:

Here is request:

https://www.googleapis.com/customsearch/v1?q=Montenegro&cx=002715630024689775911%3Ajczmrpp_vpo&num=10&key={YOUR_API_KEY}

num=10 is number of results


400 Bad Request

- Show headers -

{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}

回答1:


Well It is not possible to get more than 10 result from Google Custom Search API. https://developers.google.com/custom-search/v1/using_rest#query-params As You can see for num parameter you valid values are only between 1 and 10 inclusive.

To get more result you should make multiple calls. in each different call, increase the value of parameter 'start' by 10. That should do it




回答2:


For first page result, use https://www.googleapis.com/customsearch/v1?q=Montenegro&cx=002715630024689775911%3Ajczmrpp_vpo&num=10&start=1&key={YOUR_API_KEY}

This query asks google to provide 10 results starting from position 1. Now you can not ask google for more than 10 results at a time. So you have to query again asking for 10 result starting from 11. So In next query, keep num=10 and start=11. Now you can get all the results by changing start value.



来源:https://stackoverflow.com/questions/17427837/googlecustom-api-number-of-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!