繁体   English   中英

从 chrome 扩展程序进行谷歌搜索

[英]Make a google search from chrome extension

我正在尝试编写一个简单的 chrome 扩展程序,它将从文本框中获取输入并进行谷歌图像搜索并在扩展程序的窗口中显示结果。

我试过使用 GET 表单,但这似乎根本不起作用。 我正在尝试获取他们的 JSAPI(来自https://developers.google.com/web-search/docs/?hl=en )并且在安慰。

Google 似乎希望我使用他们的自定义搜索引擎 (CSE) 功能,但它不是一个网站,我从它的扩展程序中执行此操作。

您可以使用自定义搜索 API ,而不是使用自定义搜索引擎及其构建器,它是自定义搜索引擎的可自定义扩展。

此外,Google Chrome 扩展程序基本上是一个可以访问其他 API 和功能的网页(尤其是对用户浏览体验的有限控制)。


编辑(2020 年 12 月 22 日):截至 2016 年 10 月 24 日,Google 似乎停止支持上面链接的自定义搜索 API。 请参阅更新的Programmable Search Element Control API v2 ,其功能不同但仍应回答原始问题。

相关代码片段演示了新 API 的基本用法,从链接页面修改:

 <!-- Put the following javascript before the closing </head> tag and replace 123:456 with your own Programmable Search Engine ID. --> <!-- NOTE: I've replaced "123:456" with the example ID from the documentation page --> <script async src="https://cse.google.com/cse.js?cx=000888210889775888983:y9tkcjel090"></script> <!-- Place this tag where you want both of the search box and the search results to render --> <div class="gcse-search"></div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM