簡體   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