【发布时间】:2015-03-02 11:31:51
【问题描述】:
我们希望使用 Google 自定义搜索实现 Google 附加链接搜索框。在 Google documentation 中,我发现我们需要包含以下代码才能启用附加链接搜索框
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://www.example-petstore.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://query.example-petstore.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
但是我们被困在上述属性中的“目标”节点。由于我们没有自己的搜索页面,我们想使用谷歌自定义搜索,所以我应该在这个“目标”节点填写什么值。
我们已经为我们的网站创建了一个 Google 自定义搜索引擎。并在下面找到了代码
<script>
(function() {
var cx = 'CX_ID';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
请建议,如何在附加链接搜索框代码中指向 Google 自定义搜索。
谢谢
【问题讨论】:
-
也许this 会帮助你。
-
感谢@Shishdem 的回复。但是这个链接也指向同一个谷歌documentation :(
-
还有什么建议吗??
-
不,不是我这边。在我的回答中,我解释了什么是可能的,什么是不可能的——显然你需要自己深入研究文档。或者实现一个搜索页面——你应该很好地使用谷歌自定义搜索。
标签: google-oauth google-custom-search google-search-api