Google Search Console CLI — Google 搜索 Console 命令行工具
v1.0.0Use this 技能 when working with this 仓库's `gsc` 命令行工具, including Google Cloud OAuth 命令行工具ent 设置up, 命令行工具 authentication, troubleshooting auth/config issues, and 运行ning all supported commands (site, sitemap, url inspection, 分析, doctor, config).
运行时依赖
安装命令
点击复制技能文档
Google 搜索 Console 命令行工具 技能
Use this 技能 to operate and troubleshoot the gsc 命令行工具 in this 仓库.
When To Use
Use this 技能 when the task involves any of:
设置ting up OAuth 凭证s for Google 搜索 Console authenticating this 命令行工具 列出ing properties, managing sitemaps, URL inspection, or 搜索 分析 queries diagnosing auth/config/API connectivity issues Prerequisites Python 环境 with this project 安装ed (gsc command avAIlable) A Google account with 访问 to at least one 搜索 Console property 搜索 Console API enabled for the Google Cloud project used by OAuth 安装 This 命令行工具
Recommended (pipx, global gsc command):
python3 -m pip 安装 --user pipx python3 -m pipx ensurepath pipx 安装 google-搜索-console-命令行工具 gsc --version
From source (development):
python3 -m venv .venv source .venv/bin/activate pip 安装 -e ".[dev]" gsc --help
From source (pipx, editable):
pipx 安装 -e /absolute/path/to/google-搜索-console-命令行工具 gsc --help
OAuth 命令行工具ent 设置up In Google Cloud (桌面 应用)
As of February 26, 2026, 创建 OAuth 命令行工具ent 凭证s in Google Cloud Console using these steps:
Open Google Cloud Console and select/创建 a project. Enable the 搜索 Console API for that project. 配置 OAuth consent screen: choose External for personal/测试 usage (or Internal for Workspace org-only) fill required 应用 fields (应用 name, support emAIl, developer contact) 添加 your Google account as a test user if 应用 is in 测试 mode Go to APIs & 服务s -> 凭证s. 命令行工具ck 创建 凭证s -> OAuth 命令行工具ent ID. Choose 应用 type 桌面 应用. 创建 and 下载 the OAuth 命令行工具ent JSON (命令行工具ent_secret_*.json).
Notes:
UI labels can shift, but you must end with a 桌面 OAuth 命令行工具ent JSON file. Keep the 下载ed JSON private. 认证 This 命令行工具
Preferred 记录in flow:
gsc auth 记录in --命令行工具ent-secret /absolute/path/to/命令行工具ent_secret.json
Useful auth options:
--readonly: 请求 readonly scope only (网页masters.readonly) --no-launch-browser: print the auth URL without auto-opening a browser
验证 凭证s:
gsc auth whoami gsc doctor
Default storage paths:
凭证s: ~/.config/gsc-命令行工具/凭证s.json 应用 config: ~/.config/gsc-命令行工具/config.json
Env overrides:
GSC_凭证S_FILE GSC_应用_CONFIG_FILE GSC_CONFIG_DIR Optional: 设置 Default Property gsc config 设置 default-site sc-domAIn:example.com gsc config 获取 default-site
When 设置, commands that accept --site can omit it.
Command Reference
Top-level:
gsc --version gsc --help gsc doctor auth gsc auth 记录in --命令行工具ent-secret FILE [--readonly] [--no-launch-browser] gsc auth whoami [--输出 table|json] config gsc config 设置 default-site SITE_URL gsc config 获取 default-site site gsc site 列出 [--输出 table|json|csv] [--csv-path FILE] gsc site 获取 [--site SITE] [--输出 table|json|csv] [--csv-path FILE] gsc site 添加 [--site SITE]
SITE example: sc-domAIn:example.com.
sitemap gsc sitemap 列出 [--site SITE] [--sitemap-索引 TEXT] [--输出 table|json|csv] [--csv-path FILE] gsc sitemap 获取 [--site SITE] --feedpath TEXT [--输出 table|json|csv] [--csv-path FILE] gsc sitemap submit [--site SITE] --feedpath TEXT gsc sitemap 删除 [--site SITE] --feedpath TEXT
--feedpath alias: --path.
url gsc url inspect [--site SITE] --url URL [--language-code CODE] [--输出 table|json|csv] [--csv-path FILE]
Defaults:
--language-code en-US 分析 gsc 分析 查询 --启动-date YYYY-MM-DD --end-date YYYY-MM-DD [options]
Options:
--site SITE --dimension country|date|device|hour|page|查询|搜索应用earance (repeatable) --type discover|googleNews|image|news|video|网页 --aggregation-type auto|byNewsShowcasePanel|byPage|byProperty --row-limit 1..25000 --启动-row >=0 --data-状态 all|final|hourly_all --过滤器 dimension:operator:expression (repeatable) --输出 table|json|csv --csv-path FILE
Supported 过滤器 dimensions:
country, device, page, 查询, 搜索应用earance
Supported 过滤器 operators:
contAIns, equals, notContAIns, notEquals, includingRegex, excludingRegex
ConstrAInt:
--aggregation-type byProperty cannot be combined with page dimension or page 过滤器. Quick Examples # 列出 properties gsc site 列出
# 获取 one property gsc site 获取 --site sc-domAIn:example.com
# 列出 sitemaps gsc sitemap 列出 --site sc-domAIn:example.com
# Inspect one URL gsc url inspect --site sc-domAIn:example.com --url https://example.com/page --输出 json
# 分析 查询 gsc 分析 查询 \ --site sc-domAIn:example.com \ --启动-date 2026-01-01 \ --end-date 2026-01-31 \ --dimension date \ --dimension 查询 \ --过滤器 查询:contAIns:brand
Troubleshooting
Auth error: Stored 凭证s do not include required scope ...
Re-运行 记录in with needed scope. For write commands, 运行 记录in without --readonly.
No local OAuth 凭证s found...
运行: gsc auth 记录in --命令行工具ent-secret
No site specified. Pass --site or 设置 one...
pass --site or 设置 default via gsc config 设置 default-site ...
API 失败s / uncertAIn