我完全不知道如何将 Google 的附加链接搜索框与 Google 的自定义搜索结合使用。
有人知道我是如何开始连接 2 的吗?
对于站点链接搜索框,Google 提供以下代码:
<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>
然后你就有了谷歌的自定义搜索代码:
<script>
(function() {
var cx = '006674923042857018221:WMX2084923030';
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>
我到底如何连接2?希望你能指出我正确的方向。