怎么在命令行中集成Google 搜索。
接口地址
https://www.googleapis.com/customsearch/v1?key={API密钥}&q={搜索关键词}&cx={YOUR_CX}&start={10}&num={10}
获得API 密钥:https://console.cloud.google.com/apis/credentials
获得CX:https://programmablesearchengine.google.com/controlpanel/all
这是返回的JSON 搜索数据,就这么简单。
![googleapi 可编程搜索 JSON](https://markbuild.com/wp-content/uploads/2022/10/googleapi-search-result.jpg)
![Google 创建可编程搜索](https://markbuild.com/wp-content/uploads/2022/10/google-create-new-search.jpg)
![获取Google CX](https://markbuild.com/wp-content/uploads/2022/10/google-get-cx.jpg)
![获取Google Search API Key](https://markbuild.com/wp-content/uploads/2022/10/google-get-api-key.jpg)
Google 搜索API 有免费搜索次数的限制,但对于个人搜索基本也够用。
集成到我的私人搜索工具
![google 搜索终端版](https://markbuild.com/wp-content/uploads/2022/10/personal-google-search.jpg)
对比下网页版
![](https://markbuild.com/wp-content/uploads/2022/10/google_search_normal.jpg)
![google 搜索终端版翻页](https://markbuild.com/wp-content/uploads/2022/10/personal-google-search-change-page.jpg)
![google 搜索手机shell版](https://markbuild.com/wp-content/uploads/2022/10/iSH-google-search.webp)
![google 搜索手机shell版翻页](https://markbuild.com/wp-content/uploads/2022/10/iSH-google-search-change-page.webp)
API 参考文档:
https://developers.google.com/custom-search/v1/reference/rest/v1/Search