Google CSE:显示结果计数
我已经为我的网站实现了 Google 站点搜索/自定义搜索,一切正常,结果格式化且分页良好。但它永远不会像在 Google 上搜索时那样返回找到的结果数量 大约 1,660,000 个结果(0.16 秒)
我想知道是否有人找到了可以执行此操作的任何内容,但我找不到文档中的任何内容。
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('GOOGLEIDGOESHERE');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.setNoResultsString("No results found.")
customSearchControl.draw('cse');
}, true);
</script>
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
I've implemented Google site search / Custom search for my website and it is all working and results are formatted and paging fine. But it never returns a count of how many results it found like it does when you search on Google About 1,660,000 results (0.16 seconds)
I was wondering if anyone had found anything to do this i can't find anything in there documentation.
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('GOOGLEIDGOESHERE');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.setNoResultsString("No results found.")
customSearchControl.draw('cse');
}, true);
</script>
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要使用 SearchCompleteCallback 并深埋在混淆的 javascript 库中,您将找到estimatedResultCount 属性。这是一个弹出带有计数的警报的简单示例。您可以通过使用 jquery 插入一些带有您喜欢的任何格式的计数的 html 来定制它以满足您的需求。
You will need to use the SearchCompleteCallback and buried deep within the obfuscated javascript library, you will find the estimatedResultCount property. Here's a quick example that pops up an alert with the count. You can tailor this to meet your needs by using jquery to insert some html with the count in any format you like.