一套 Google Search Console / Indexing API 自动提交方案(可实操版),包含原理、限制、完整流程、代码示例和架构建议。
一、先说清楚:Search Console vs Indexing API
1️⃣ Search Console
没有官方“批量自动提交 URL API”
它主要用于:
查看收录状态
手动“请求编入索引”
⚠️ 没有公开接口让你批量提交 URL
2️⃣ 真正能自动提交的是:Indexing API
官方地址:
https://indexing.googleapis.com/v3/urlNotifications:publish
官方用途:
Job Posting(招聘)
Live Stream(直播)
⚠️ 现实情况: SEO 圈很多人用于普通页面(有一定效果)
二、Indexing API 自动提交原理
流程如下:
你的网站 ↓ 调用 Google Indexing API ↓ Google 收到 URL 通知 ↓ 优先安排抓取 ↓ 可能收录(不保证)
三、完整自动化方案(推荐架构)
自动提交流程:
新页面发布 ↓ 写入数据库 ↓ 触发 API 提交 ↓ 记录提交状态 ↓ 定时重试失败 URL
四、准备工作(必须做)
1️⃣ 创建 Google Cloud 项目
https://console.cloud.google.com/
创建项目
启用 API:
✅ Indexing API
2️⃣ 创建 Service Account
创建服务账号
下载 JSON key
3️⃣ Search Console 绑定权限(关键)
把 Service Account 加到站点:
路径:
Search Console → 设置 → 用户和权限 → 添加用户
添加:
xxx@xxx.iam.gserviceaccount.com
权限:所有者
五、API 调用示例
1️⃣ 请求结构
POST https://indexing.googleapis.com/v3/urlNotifications:publish
{
"url": "https://yourdomain.com/page-url",
"type": "URL_UPDATED"
}2️⃣ Python 示例(推荐)
from google.oauth2 import service_account
from google.auth.transport.requests import Request
import requests
import json
SCOPES = ["https://www.googleapis.com/auth/indexing"]
SERVICE_ACCOUNT_FILE = "service_account.json"
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES
)
credentials.refresh(Request())
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {credentials.token}",
}
data = {
"url": "https://yourdomain.com/page-url",
"type": "URL_UPDATED"
}
response = requests.post(
"https://indexing.googleapis.com/v3/urlNotifications:publish",
headers=headers,
data=json.dumps(data)
)
print(response.text)3️⃣ Node.js 示例
const { google } = require("googleapis");
const auth = new google.auth.GoogleAuth({
keyFile: "service_account.json",
scopes: ["https://www.googleapis.com/auth/indexing"],
});
async function submitUrl() {
const client = await auth.getClient();
const url = "https://indexing.googleapis.com/v3/urlNotifications:publish";
const res = await client.request({
url,
method: "POST",
data: {
url: "https://yourdomain.com/page-url",
type: "URL_UPDATED",
},
});
console.log(res.data);
}
submitUrl();六、自动化部署方案(重点)
方案1:发布时自动提交(推荐)
触发点:
CMS 发布文章时
实现:
onPublish(): 调用 Indexing API
适用于:
WordPress
自建CMS
Next.js / Nuxt
方案2:批量提交脚本
每天定时任务: 查询未收录URL 批量提交API
方案3:失败重试机制(很重要)
如果返回失败: 加入队列 1小时后重试 最多重试3次
七、配额限制(必须知道)
官方限制:
每天约 200 URL / 天 / 项目
查询接口:
GET urlNotifications/metadata
实际经验:
超过会被限流
可以:
多项目分流(高级玩法)
八、最佳实践(核心经验)
✅ 1. 只提交重要页面
新文章
更新内容
高价值页面
✅ 2. 控制提交频率
不要:
一次提交几千URL ❌
建议:
持续稳定提交 ✔
✅ 3. 搭配 Sitemap
Indexing API ≠ 替代 sitemap
必须同时做:
sitemap
内链
API 提交
九、常见问题
❓ 提交了为什么不收录?
原因:
内容质量低
网站权重低
页面重复
API只是“通知”,不是“强制收录”
❓ API 有用吗?
实测结论:
新站:有明显加速作用
老站:作用较小
高质量内容:效果最好
十、推荐最终架构(最优组合)
发布文章 ↓ 调用 Indexing API ↓ 更新 sitemap ↓ Ping Google ↓ 内部链接更新 ↓ 外链触发
如果你要更狠一点(进阶)
可以帮你设计:
多账号分布式提交系统
自动检测“已收录 vs 未收录”
批量站群收录策略
API + 外链联动模型
