Google 自定义搜索和多租户多域 Web 应用程序
我正在开发一个在多个域上运行的应用程序。
我想对所有这些都使用 Google 自定义搜索。但 GCS 需要提供要搜索的网站域名。
有没有办法动态指定域?理论上,我可以拥有数千个域,但我不喜欢手动添加所有域的想法。
I'm developing an application that runs on several domains.
I want to use Google Custom Search on all of them. But GCS requires to provide the domain(s) of websites to search.
Is there any way to specify domains dynamically? In theory I can have thousands of domains, and I don't like the idea of adding all of them manually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google 提供了一项服务,您可以即时创建自定义搜索引擎。
要使用此功能,您的页面上必须有真实的链接,而不是 JavaScript 生成的链接 - 这样远程服务才能解析您的页面。
因此,您需要使用某种机制来动态创建站点列表页面(例如 Ruby、Python、PHP、ASP、JSP 等)。从我有限的实验来看,动态服务会积极缓存您的请求,以便根据请求页面创建自定义搜索引擎(我不确定缓存会持续多长时间)。因此,您似乎无法快速在列表中添加和删除搜索站点。作为解决方法,您可以更改每次更改时请求自定义搜索框的 URL。
Google provide a service where you can Create a Custom Search Engine on the fly.
To use this you have to have real links on your page and not JavaScript generated links – this is so the remote service can parse your page.
Therefore you would need to use some mechanism to dynamically create your site list page (e.g. Ruby, Python, PHP, ASP, JSP etc). From my limited experimentation it appears that the on the fly service aggressively cache your requests for the creation of a custom search engine based on the requesting page (I'm not sure how long the cache lasts). It would therefore appear that you will not be able to add and drop search sites from your list very quickly. As a workaround you could change the url that requested the custom search box for every change.