gpt4 book ai didi

multi-tenant - Google 自定义搜索和 Multi-Tenancy 多域 Web 应用程序

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

我正在开发一个在多个域上运行的应用程序。

我想对所有这些都使用 Google 自定义搜索。但是 GCS 需要提供要搜索的网站域。

有没有办法动态指定域?理论上,我可以拥有数千个域,但我不喜欢手动添加所有域的想法。

最佳答案

Google 提供的服务,您可以在其中 Create a Custom Search Engine on the fly .

要使用它,您的页面上必须有真正的链接,而不是 JavaScript 生成的链接——这样远程服务才能解析您的页面。

<form name="cse" id="searchbox_demo" action="http://www.google.com/cse">
<input type="hidden" name="cref" value="" />
<input type="hidden" name="ie" value="utf-8" />
<input type="hidden" name="hl" value="" />
<input name="q" type="text" size="40" />
<input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="http://www.google.co.uk/cse/tools/onthefly?form=searchbox_demo&lang="></script>
<a href="http://www.stackoverflow.com">stackoverflow</a><br />
<a href="http://serverfault.com/">serverfault</a><br />
<a href="http://superuser.com/">superuser</a>

因此,您需要使用某种机制来动态创建站点列表页面(例如 Ruby、Python、PHP、ASP、JSP 等)。从我有限的实验来看,动态服务似乎会根据请求页面积极缓存您创建自定义搜索引擎的请求(我不确定缓存持续多长时间)。因此,您似乎无法在列表中快速添加和删除搜索站点。作为一种解决方法,您可以更改为每次更改请求自定义搜索框的 url。

关于multi-tenant - Google 自定义搜索和 Multi-Tenancy 多域 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7882583/

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