gpt4 book ai didi

google-oauth - 带有 Google 自定义搜索功能的 Google 附加链接搜索框

转载 作者:行者123 更新时间:2023-12-04 15:43:24 26 4
gpt4 key购买 nike

我们想使用 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>

我们想要实现像 Mashable 这样的附加链接搜索框, Imdb

enter image description here

请建议,如何在附加链接搜索框代码中指向 Google 自定义搜索。

谢谢

最佳答案

唯一的解决办法:

为此,您需要在自己的网站上有一个搜索页面。

For the "target" parameter, do a search on your site and take that URL and replace the search term you used to do the search with "{search_term_string}"



如果您在自己的网站上创建了一个使用自定义 Google 搜索的搜索页面,您应该能够获取该链接以获取 target -属性(property)。

原因是谷歌没有提供搜索功能

will send the user directly to your website's own search pages.



资料来源:
  • http://googlewebmastercentral.blogspot.ro/2014/09/improved-sitelinks-search-box.html
  • http://www.seocandy.co.uk/seo/setup-google-sitelink-search/
  • 关于google-oauth - 带有 Google 自定义搜索功能的 Google 附加链接搜索框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808763/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com