简体   繁体   English

google自定义搜索限制没有结果

[英]google custom search limit no of results

i want to get on top 40 result from google api when i am limiting the result using the below given code it not working ,so how can i get top 40 result by the google api 当我使用以下给定的代码限制结果时,我想从Google api获得前40名的结果,所以我怎么能通过Google api获得前40名的结果

<script>
    (function() {
        var cx = '006925870720824680899:dalusahelrm';
        var gcse = document.createElement('script');
        gcse.type = 'text/javascript';
        gcse.async = true;
        gcse.src = 'https://cse.google.com/cse.js?cx=' + cx+"&start=1&num=40';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(gcse, s);
    })();
</script>
<gcse:search></gcse:search> 

Try adding the "webSearchResultSetSize" attribute to your Search Element. 尝试将“ webSearchResultSetSize”属性添加到搜索元素。 It will let you have up to 20 results per page. 每页最多可以显示20个结果。 See https://developers.google.com/custom-search/docs/element#supported_attributes 请参阅https://developers.google.com/custom-search/docs/element#supported_attributes

Something like this: 像这样:

<script>
(function() {
    var cx = '006925870720824680899:dalusahelrm';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search webSearchResultSetSize=20></gcse:search>

As per the official documentation , it's not possible to return more than 10 results in a single request. 根据官方文档 ,单个请求最多不能返回10个以上的结果。

Valid values are integers between 1 and 10, inclusive. 有效值是1到10之间(包括1和10)的整数。

This Google support document suggests that you perform additional queries, and increment your start value if you want to fetch more than 10 results. 该Google支持文档建议您执行其他查询,如果要获取10个以上的结果,请增加起始值。

Google Custom Search and Google Site Search return up to 10 results per query. Google自定义搜索和Google站点搜索每个查询最多返回10个结果。 If you want to display more than 10 results to the user, you can issue multiple requests (using the start=0, start=11 ... parameters) and display the results on a single page. 如果要向用户显示10个以上的结果,则可以发出多个请求(使用start = 0,start = 11 ...参数)并将结果显示在单个页面上。 In this case, Google will consider each request as a separate query, and if you are using Google Site Search, each query will count towards your limit. 在这种情况下,Google会将每个请求视为一个单独的查询,如果您使用的是Google Site Search,则每个查询都将计入您的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM