使用 Google 搜尋圖像,無需使用自訂搜尋 JSON/Atom API
要安裝,您只需在 NodeJS 專案中執行以下命令即可:
npm install free-google-image-search --save
或者這個:
yarn add free-google-image-search
庫的使用非常簡單。您需要做的就是呼叫 .searchImage 函數並傳入所需的搜尋查詢。這是一個簡單的範例程式碼:
import GoogleImageSearch from 'free-google-image-search'
GoogleImageSearch . searchImage ( "cats" )
. then ( ( res ) => {
console . log ( res ) ; // This will return array of image URLs
} )
庫目前返回一組谷歌圖像縮圖。
請隨意提交問題和附魔請求
請您了解「fork-and-pull」Git 工作流程
請參考以下程式碼樣式指南
請主要將該庫用於測試目的。在生產環境中可能不穩定