关于 Google Search (via Apify)
这是一个 Apify Actor,以兼容 Google Custom Search JSON API 的格式返回实时网页和图片搜索结果。开发者和 Agent 可用它替换原端点,并沿用熟悉的请求参数和响应字段。
主要功能
- 01兼容 Custom Search JSON 的端点
- 02网页和图片搜索结果
- 03支持常用搜索参数
- 04兼容 SearXNG 的响应路由
适用场景
- 01替换 Custom Search API 端点
- 02向搜索客户端提供 Google 结果
- 03以 JSON 获取图片搜索结果
MCP 相关
可通过 Apify 托管的 MCP 服务使用,让 MCP 客户端和 AI Agent 执行搜索。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://mcp.apify.com/?tools=automationnation/google-custom-search-apiclaude mcp add --transport http retracn-google-search https://mcp.apify.com/?tools=automationnation/google-custom-search-api{"mcpServers":{"retracn-google-search":{"type":"http","url":"https://mcp.apify.com/?tools=automationnation/google-custom-search-api"}}}在 Cursor 中打开{"servers":{"retracn-google-search":{"type":"http","url":"https://mcp.apify.com/?tools=automationnation/google-custom-search-api"}}}在 VS Code 中打开{"mcpServers":{"retracn-google-search":{"type":"http","url":"https://mcp.apify.com/?tools=automationnation/google-custom-search-api"}}}{"mcpServers":{"retracn-google-search":{"serverUrl":"https://mcp.apify.com/?tools=automationnation/google-custom-search-api"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://mcp.apify.com/?tools=automationnation/google-custom-search-api需要授权工具
详细介绍
Google Custom Search JSON API 替代方案:相同请求,相同 JSON
Google Custom Search API 替代方案是一个 Apify Actor,可替代 Google 的 Custom Search JSON API。Google 已停止接受新客户,并将于 2027 年 1 月 1 日停用该 API。它使用实时 Google 搜索结果处理相同的 /customsearch/v1 请求,并返回相同的 JSON(包含 title、link、displayLink 和 snippet 的 items,以及图片搜索),每 1,000 次搜索收费 $5,且没有每日上限。
价格: 每 1,000 次搜索(每次最多 10 条结果)收费 $5(Gold 及以上套餐为 $4) · 运行地址: https://apify.com/automationnation/google-custom-search-api · 指南: https://retracn.github.io/automationnation-actors/google-custom-search-api/
快速信息
- 即插即用端点:将 https://www.googleapis.com/customsearch/v1 替换为 https://automationnation--google-custom-search-api.apify.actor/customsearch/v1,并发送 Apify token(token=… 或 Authorization: Bearer),而不是 key=。
- 相同参数:q、num、start、gl、hl、lr、cr、safe、dateRestrict、siteSearch、exactTerms、excludeTerms、orTerms、fileType 和 searchType=image(及其图片过滤器);cx 会被接受但忽略。
- Open WebUI:选择 External web search engine,将 URL 设为 https://automationnation--google-custom-search-api.apify.actor/search,并将 Apify token 作为密钥,这样在 Google PSE 停止接受新客户后仍可使用 Google 搜索结果。
- 兼容 SearXNG 的路由,适用于 AnythingLLM 和其他 SearXNG 客户端:https://automationnation--google-custom-search-api.apify.actor/searxng?token=YOUR_APIFY_TOKEN 会以 SearXNG 的 JSON 格式返回 Google 搜索结果。
- 相同 JSON:kind、queries.request 和 nextPage、searchInformation,以及包含 title、htmlTitle、link、displayLink、snippet、htmlSnippet 和 formattedUrl 的 items[](图片结果还包含 mime 和 image.contextLink、width、height、byteSize、thumbnailLink)。
- 网页搜索使用 Google 的“Web”结果视图:每页 10 条普通结果,不含 AI Overview、广告、视频和论坛信息框,接近该 API 的返回结果。
- 差异:搜索范围为整个网络(通过 siteSearch 或 site: 运算符传入站点列表),totalResults 是下限,没有 pagemap,且每个请求耗时约 4–10 秒。
- 价格:每 1,000 次搜索(每次最多 10 条结果)收费 $5,与 Google 的收费相同;没有结果的搜索免费,且没有每日上限。
将其用作即插即用的 Custom Search JSON API
更改端点和密钥;其余代码保持不变:
| 更改前 | 更改后 | |
|---|---|---|
| 端点 | https://www.googleapis.com/customsearch/v1 | https://automationnation--google-custom-search-api.apify.actor/customsearch/v1 |
| 身份验证 | key=YOUR_GOOGLE_KEY&cx=YOUR_ENGINE_ID | token=YOUR_APIFY_TOKEN 或请求头 Authorization: Bearer YOUR_APIFY_TOKEN |
curl "https://automationnation--google-custom-search-api.apify.actor/customsearch/v1?q=best+crm+for+startups&num=10&token=$APIFY_TOKEN"
Python(examples/cse_requests.py)和 JavaScript(examples/cse_fetch.mjs)版本位于 examples/ 中。响应是该 API 的 JSON:items[].title、link、displayLink、snippet、queries.nextPage 和 searchInformation;searchType=image 同样可用。
示例输入
{
"queries": [
"best project management software"
],
"maxResultsPerQuery": 10
}
通过代码运行
REST API
curl -X POST "https://api.apify.com/v2/acts/automationnation~google-custom-search-api/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"queries": ["best project management software"], "maxResultsPerQuery": 10}'
Python — 参见 examples/python_example.py
# pip install apify-client
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("automationnation/google-custom-search-api").call(run_input={
"queries": [
"best project management software"
],
"maxResultsPerQuery": 10
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item.get("title"), item.get("link"), item.get("displayLink"), item.get("snippet"))
JavaScript — 参见 examples/node_example.mjs
// npm install apify-client
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('automationnation/google-custom-search-api').call({
"queries": [
"best project management software"
],
"maxResultsPerQuery": 10
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
for (const item of items) console.log(item.title, item.link, item.displayLink, item.snippet);
将其与 AI Agent 配合使用(MCP)
托管 MCP 服务 URL(适用于 Claude、ChatGPT、Cursor 及其他支持远程 MCP 的客户端):
https://mcp.apify.com?tools=automationnation/google-custom-search-api
Claude Desktop / Cursor 的本地配置 — mcp/claude_desktop_config.json:
{
"mcpServers": {
"google-custom-search-api": {
"command": "npx",
"args": [
"-y",
"@apify/actors-mcp-server",
"--tools",
"automationnation/google-custom-search-api"
],
"env": {
"APIFY_TOKEN": "YOUR_APIFY_TOKEN"
}
}
}
}
常见问题
Custom Search JSON API 什么时候会停止工作? Google 已停止向新客户开放该 API,并表示现有客户需在 2027 年 1 月 1 日前迁移到其他方案。
我需要重写代码吗? 不需要。将端点改为 https://automationnation--google-custom-search-api.apify.actor/customsearch/v1,并使用 Apify API token 替代 Google 密钥;参数和 JSON 响应保持不变。
我可以保留 Programmable Search Engine 的网站列表吗? 不能通过 cx 实现,因为 cx 会被忽略。请将一个网站作为 siteSearch 传入,或在查询中添加多个网站,例如 site:a.com OR site:b.com。
费用是多少? 每 1,000 次搜索收费 $5,每次最多返回 10 条结果(Silver 方案收费 $4.50,Gold 及以上方案收费 $4),且没有每日上限。Google 在每天 100 次免费查询后,每 1,000 次收费 $5;Apify 免费方案包含 $5 的月度额度,约可用于 1,000 次搜索。
更多 AutomationNation 内容
- AI 可见度追踪器 — 每检查一个答案 $0.05(Gold 用户为 $0.04)+ 每份可选报告 $0.50 · GitHub 示例
- Google Jobs 抓取工具 — 每 1,000 个职位 $2(付费套餐为 $1.50)+ 每次搜索 $0.03 · GitHub 示例
- YouTube 字幕抓取工具 — 每 1,000 份字幕 $1.50(Gold 及以上套餐为 $1.20)· GitHub 示例
- Google Shopping 抓取工具 — 每 1,000 件商品 $1(Gold 及以上套餐为 $0.80)· GitHub 示例
- Google Flights 抓取工具 — 每 1,000 个航班 $0.20(Gold 及以上套餐为 $0.16)· GitHub 示例
- Google Hotels 抓取工具 — 每 1,000 家酒店 $1(Gold 及以上套餐为 $0.80)· GitHub 示例
- Google Ads Transparency 抓取工具 — 每 1,000 条广告 $1(Gold 及以上套餐为 $0.80)· GitHub 示例
- Google News 抓取工具 — 每 1,000 篇文章 $1(Gold 及以上套餐为 $0.80)· GitHub 示例
- Google 图片抓取工具 — 每 1,000 张图片 $0.25(Gold 及以上套餐为 $0.20)· GitHub 示例
- Google 视频抓取工具 — 每 1,000 个视频 $1(Gold 及以上套餐为 $0.80)· GitHub 示例
- Google Trends 抓取工具 — 每 1,000 份关键词报告 $1(付费套餐为 $0.27–$0.90)· 每 1,000 条热门搜索 $0.50 · GitHub 示例
- App Store 评论抓取工具 — 每 1,000 条评论 $0.08(付费套餐为 $0.05–$0.07)· GitHub 示例
- Google Play 评论抓取工具 — 每 1,000 条评论 $0.08(付费套餐为 $0.05–$0.07)· GitHub 示例
- AEO 和 GEO 追踪器 — Google AI Overview 引用检查工具 — 每个关键词 $0.04(Gold 用户为 $0.032),自 2026 年 11 月 17 日起每次运行另收 $2;截至 2026 年 10 月 16 日,每个关键词 $0.01 · GitHub 示例
- Google Maps 潜在客户抓取工具 — 每条潜在客户信息 $0.03(Gold 用户为 $0.024);使用无网站或未认领筛选条件时,每找到一家企业收费 $0.08 · GitHub 示例
- Google Maps 英国潜在客户抓取工具 — 每条潜在客户信息 $0.05(Gold 用户为 $0.04)· GitHub 示例
- App Store 和 Google Play 评论抓取工具 + AI — 每份应用报告 $0.05(Gold 用户为 $0.04)· GitHub 示例
- 英国 Companies House 潜在客户 — 申报信号和 AI 外联 — 每条潜在客户信息 $0.008
- 联系人瀑布式丰富 — 电子邮件和董事 — 每家公司 $0.015
- 所有 Actors 和指南 · AI 可见度追踪器对比 · Google Jobs 抓取工具对比 · Google Trends 抓取工具对比 · App Store 评论抓取工具对比 · Google Play 评论抓取工具对比 · YouTube 字幕抓取工具对比 · Google Flights 抓取工具对比 · Google Hotels 抓取工具对比 · Google Ads Transparency 抓取工具对比 · Google Shopping 抓取工具对比 · Google News 抓取工具对比
此仓库包含使用示例。爬虫本身运行在 Apify 平台 上;你需要一个免费的 Apify 账户和 API 令牌。示例采用 MIT 许可证。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。