To find new post ideas, I used to open the Performance report in Google Search Console and scroll for queries that got impressions but no clicks. Same report, same sort order, one page at a time. I gave up after three days.
So I wrote a small Python script that pulls the numbers from the Search Console API every morning and lists only the queries where my blog shows up but hardly anyone clicks. Claude Code reads that list and suggests which ones are worth a post. Task Scheduler runs the script at 7:00, so by the time I sit down, the list is waiting. I paste one line and look over the picks.

What the Search Console API gives you that the report does not
The Search Console API is Google's free way to pull the same numbers you see in the Performance report (clicks, impressions, CTR and average position) from a script. Roughly, the difference looks like this.
| Performance report | Search Console API | |
|---|---|---|
| Rows | Up to 1,000 rows on screen and in exports | Up to 25,000 rows per request, with paging for more |
| Query by page | Pick one page, then see its queries | Every query and page pair at once |
| Daily work | Open, filter and sort by hand | Run a script on a schedule |
| Setup | None | Create a service account key and add it as a user in Search Console |
With a handful of posts, the report is fine. My blog passed 150 posts across Japanese and English, and somewhere along the way I lost track of which query ranked which post where. That is when I stopped doing it by hand.
What counts as a content gap
By a content gap, I mean a query where Google already shows my site, but the page ranks too low to get clicked. The blog is related to the topic, but no post really answers it. Write one that does, and it might climb.
The script writes three tables. I tweaked the thresholds a few times on my own blog until the lists felt useful. They all sit at the top of the script.
| Table | Rule | What I use it for |
|---|---|---|
| Gaps (gaps.csv) | 20+ impressions in 28 days, average position 8 or lower, 1 click or fewer | New post ideas |
| Tune-ups (tune.csv) | Pages with 100+ impressions at an average position of 6 to 12 | Posts that might reach the top of page one with a better title or intro |
| Risers and fallers (moves.csv) | Pages whose clicks changed against the previous 28 days | Checking whether a fix worked, spotting sudden drops |
If your site runs on WordPress, the script also checks each gap query against your posts and labels it “dedicated post”, “mentioned in a post” or “no post”. Published posts are readable through the WordPress REST API without logging in, so no password is involved.
Setup: create a key and add it to Search Console
The API needs a service account (a Google account for a program) and its key file. Setting that up looks like this.
- In the Google Cloud console, make a new project. Then go to APIs and services > Library, search for “Google Search Console API” and click Enable
- Open IAM and admin > Service accounts > Create service account. Give it a name. It needs no roles
- Open the new service account, go to the Keys tab and choose Add key > Create new key > JSON. Save the file next to the script as
gsc-key.json - In Search Console, go to Settings > Users and permissions > Add user. Enter the email address of the service account (
name@project.iam.gserviceaccount.com) and choose Restricted
The key file is basically a spare key to your Search Console data. Do not share it, do not commit it to GitHub and do not let it show up in a screenshot. The script only asks for the read-only scope (webmasters.readonly), so it cannot change anything on your property.
On the Python side, you only need two libraries.
python -m pip install google-auth requests
The full script (gsc_morning.py)
This is where I ended up after a lot of back and forth with Claude Code, cleaned up so it works for other sites too. Change only the block marked EDIT THESE and save it as gsc_morning.py (UTF-8).
# -*- coding: utf-8 -*-
"""
gsc_morning.py
Pulls Google Search Console data and builds three tables: content gaps, posts worth a tune-up, plus risers and fallers.
Usage: python gsc_morning.py
Requires: python -m pip install google-auth requests
"""
import csv
import datetime as dt
import html
import json
import os
import re
import sys
import urllib.error
import urllib.parse
import urllib.request
from collections import defaultdict
# ===================== EDIT THESE =====================
KEY_FILE = "gsc-key.json" # Service account key (put it in the same folder as this script)
SITE = "https://example.com/" # Search Console property. For a Domain property use "sc-domain:example.com"
WP_URL = "" # For WordPress, set "https://example.com" to check which posts already use the words. Leave empty to skip
DAYS = 28 # Days to look at (compared with the same number of days before)
OUT_DIR = "gsc-out" # Output folder (one subfolder per day)
GAP_MIN_IMP = 20 # Gap: at least this many impressions
GAP_MIN_POS = 8 # Gap: average position this low at best (8 = 8th place down)
GAP_MAX_CLICK = 1 # Gap: maximum clicks
TUNE_POS = (6, 12) # Tune-up: average position in this range
TUNE_MIN_IMP = 100 # Tune-up: at least this many impressions
RECENT_DAYS = 28 # Skip posts updated within this many days (only when WP_URL is set)
# ============================================================
HERE = os.path.dirname(os.path.abspath(__file__))
SCOPES = ["https://www.googleapis.com/auth/webmasters.readonly"]
def gsc_session():
from google.oauth2 import service_account
from google.auth.transport.requests import AuthorizedSession
key = KEY_FILE if os.path.isabs(KEY_FILE) else os.path.join(HERE, KEY_FILE)
cred = service_account.Credentials.from_service_account_file(key, scopes=SCOPES)
return AuthorizedSession(cred)
def gsc_rows(sess, start, end, dims):
"""Call the Search Analytics API 25,000 rows at a time until no rows are left"""
url = "https://www.googleapis.com/webmasters/v3/sites/{}/searchAnalytics/query".format(
urllib.parse.quote(SITE, safe=""))
rows, start_row = [], 0
while True:
body = {"startDate": str(start), "endDate": str(end), "dimensions": dims,
"rowLimit": 25000, "startRow": start_row, "type": "web"}
r = sess.post(url, json=body)
if r.status_code != 200:
sys.exit("Search Console API error {}: {}".format(r.status_code, r.text[:300]))
got = r.json().get("rows", [])
rows += got
if len(got) < 25000:
return rows
start_row += 25000
def wp_posts():
"""Fetch every published post (title, body, last modified) from the public REST API, no login needed"""
posts, page = [], 1
while True:
url = "{}/?rest_route=/wp/v2/posts&per_page=100&page={}&_fields=link,title,content,modified".format(
WP_URL.rstrip("/"), page)
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 gsc_morning"})
try:
chunk = json.load(urllib.request.urlopen(req, timeout=60))
except urllib.error.HTTPError as e:
if e.code == 400 and page > 1: # past the last page
return posts
raise
for p in chunk:
title = html.unescape(p["title"]["rendered"])
body = html.unescape(re.sub(r"<[^>]+>", " ", p["content"]["rendered"]))
posts.append({"link": p["link"], "title": title, "modified": p["modified"][:10],
"text": (title + " " + body).lower()})
if len(chunk) < 100:
return posts
page += 1
def words(query):
"""Split a query into words. Splits on spaces and also where the script changes (Latin, kana, kanji),
because Japanese queries often have no spaces. Drops very short hiragana particles."""
out = []
for w in re.split(r"[\s ]+", query.lower()):
for t in re.findall(r"[a-z0-9.+#_-]+|[ァ-ヶー]+|[一-龥々]+|[ぁ-ん]+|[^\sa-z0-9ァ-ヶーぁ-ん一-龥々]+", w):
if re.fullmatch(r"[ぁ-ん]{1,2}", t) or re.fullmatch(r"[^\w]+", t):
continue
out.append(t)
return out
def base(url):
return url.split("#")[0] # URLs with a #heading jump link count as the same post
def merge_pages(rows):
"""Merge rows per page. A #fragment URL is another view of the same result, so keep the larger number instead of adding"""
pages = defaultdict(lambda: {"clicks": 0, "imp": 0, "pos": 0.0})
for r in rows:
d = pages[base(r["keys"][0])]
if r["impressions"] > d["imp"]:
d["imp"], d["pos"] = r["impressions"], r["position"]
d["clicks"] = max(d["clicks"], r["clicks"])
return pages
def save_csv(path, header, rows):
with open(path, "w", encoding="utf-8-sig", newline="") as f: # utf-8-sig: Excel opens it without garbled text
w = csv.writer(f)
w.writerow(header)
w.writerows(rows)
def main():
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
today = dt.date.today()
end = today - dt.timedelta(days=3) # Search Console numbers settle 2 to 3 days late
start = end - dt.timedelta(days=DAYS - 1)
p_end = start - dt.timedelta(days=1)
p_start = p_end - dt.timedelta(days=DAYS - 1)
out = os.path.join(HERE, OUT_DIR, today.strftime("%Y%m%d"))
os.makedirs(out, exist_ok=True)
sess = gsc_session()
qp = gsc_rows(sess, start, end, ["query", "page"])
now = merge_pages(gsc_rows(sess, start, end, ["page"]))
prev = merge_pages(gsc_rows(sess, p_start, p_end, ["page"]))
with open(os.path.join(out, "query-page.json"), "w", encoding="utf-8") as f:
json.dump(qp, f, ensure_ascii=False)
posts = wp_posts() if WP_URL else []
by_link = {p["link"]: p for p in posts}
# 1. Gaps: queries that get impressions but rank low and get almost no clicks
gap = defaultdict(dict)
for r in qp:
q, page = r["keys"][0], base(r["keys"][1])
if r["impressions"] >= GAP_MIN_IMP and r["position"] >= GAP_MIN_POS and r["clicks"] <= GAP_MAX_CLICK:
old = gap[q].get(page)
if not old or r["impressions"] > old["impressions"]:
gap[q][page] = r
gap_rows = []
for q, per_page in gap.items():
imp = sum(r["impressions"] for r in per_page.values())
best = min(r["position"] for r in per_page.values())
landing = " ".join(sorted(per_page))
if posts:
ws = words(q)
in_title = [p["link"] for p in posts if all(w in p["title"].lower() for w in ws)]
in_body = [p["link"] for p in posts if all(w in p["text"] for w in ws)]
verdict = "dedicated post" if in_title else ("mentioned in a post" if in_body else "no post")
else:
verdict = "-"
gap_rows.append([q, imp, round(best, 1), verdict, landing])
gap_rows.sort(key=lambda x: -x[1])
save_csv(os.path.join(out, "gaps.csv"), ["query", "impressions", "best_position", "coverage", "pages_shown"], gap_rows)
# 2. Tune-ups: posts with plenty of impressions that sit just below the top of page one
recent = (today - dt.timedelta(days=RECENT_DAYS)).isoformat()
tune_rows, waiting = [], []
for page, d in now.items():
if TUNE_POS[0] <= d["pos"] <= TUNE_POS[1] and d["imp"] >= TUNE_MIN_IMP:
mod = by_link.get(page, {}).get("modified", "")
row = [page, d["imp"], d["clicks"], round(d["pos"], 1),
round(d["clicks"] / d["imp"] * 100, 1), mod]
(waiting if mod and mod >= recent else tune_rows).append(row)
tune_rows.sort(key=lambda x: -x[1])
save_csv(os.path.join(out, "tune.csv"), ["page", "impressions", "clicks", "avg_position", "ctr_pct", "modified"], tune_rows)
# 3. Risers and fallers: change in clicks against the previous period
move_rows = []
for page in set(now) | set(prev):
a, b = prev.get(page, {"clicks": 0, "imp": 0}), now.get(page, {"clicks": 0, "imp": 0})
if a["clicks"] != b["clicks"]:
move_rows.append([page, a["clicks"], b["clicks"], b["clicks"] - a["clicks"], a["imp"], b["imp"]])
move_rows.sort(key=lambda x: -abs(x[3]))
save_csv(os.path.join(out, "moves.csv"), ["page", "clicks_before", "clicks_now", "diff", "impressions_before", "impressions_now"], move_rows)
# Markdown summary for an AI to read
L = ["# Search Console summary {}".format(today),
"Period {} to {} (compared with {} to {})".format(start, end, p_start, p_end), "",
"## 1. Gaps (impressions >= {}, position >= {}, clicks <= {})".format(GAP_MIN_IMP, GAP_MIN_POS, GAP_MAX_CLICK), "",
"| Query | Impressions | Best position | Coverage | Pages shown |", "|---|---|---|---|---|"]
L += ["| {} | {} | {} | {} | {} |".format(*r) for r in gap_rows[:40]]
L += ["", "## 2. Tune-ups (position {} to {}, impressions >= {})".format(TUNE_POS[0], TUNE_POS[1], TUNE_MIN_IMP), "",
"| Page | Impressions | Clicks | Avg position | CTR% | Modified |", "|---|---|---|---|---|---|"]
L += ["| {} | {} | {} | {} | {} | {} |".format(*r) for r in tune_rows[:15]]
L += ["", "Waiting (updated within {} days): {}".format(RECENT_DAYS, " / ".join(r[0] for r in waiting) or "none")]
L += ["", "## 3. Risers and fallers (largest change in clicks first)", "",
"| Page | Clicks before -> now | Impressions before -> now |", "|---|---|---|"]
L += ["| {} | {} -> {} | {} -> {} |".format(r[0], r[1], r[2], r[4], r[5]) for r in move_rows[:15]]
with open(os.path.join(out, "report.md"), "w", encoding="utf-8") as f:
f.write("\n".join(L) + "\n")
print("Period {} to {}".format(start, end))
print("Gaps: {} / Tune-ups: {} (waiting: {}) / Risers and fallers: {}".format(
len(gap_rows), len(tune_rows), len(waiting), len(move_rows)))
print("Saved to: " + out)
if __name__ == "__main__":
main()
Feel free to use and modify the script.
What to change
| Setting | What it is | Example |
|---|---|---|
KEY_FILE |
The key file name, or a full path if it lives elsewhere | "D:\\gsc\\gsc-key.json" |
SITE |
Your Search Console property. A URL-prefix property needs the trailing slash, a Domain property needs sc-domain: in front |
"https://example.com/" |
WP_URL |
Your WordPress site URL. Leave it empty for other platforms | "https://example.com" |
DAYS |
How many days to total up | 28 |
GAP_... and TUNE_... |
The thresholds for the gap and tune-up tables. Tighten them if the tables are too long, loosen them if they are empty | GAP_MIN_IMP = 10 |
The property name at the top left of Search Console tells you which type you have. If it starts with https://, it is a URL-prefix property. A bare domain means a Domain property.
Open PowerShell in the script's folder and run it.
python gsc_morning.py
On my blog (about 150 posts) it finished in about 7 seconds and printed this:
Period 2026-10-27 to 2026-11-23 Gaps: 21 / Tune-ups: 2 (waiting: 27) / Risers and fallers: 72 Saved to: D:\gsc\gsc-out\20261126
The dated folder holds gaps.csv, tune.csv, moves.csv and report.md, which combines all three. The CSV files open in Excel as they are.

Reading the gap table
| Coverage | Meaning | What to do |
|---|---|---|
| no post | No post contains every word of the query | First choice for a new post. Typos end up here too, so read before you pick |
| mentioned in a post | Another post touches on it in passing | Write a post just for it, or add a section to the existing one |
| dedicated post | A post has every word of the query in its title | Do not write a new one. If Google shows a different page, fix internal links or the title |
For example, my blog has a dedicated post on Windows Update stuck at 99%, but for one variant of that query Google was showing my Installation Assistant post instead. A new post would only compete with the one I already had, so I added a link from the related post to the dedicated one instead. I added the “pages shown” column to catch mismatches like that.
Run it at 7:00 every morning
Windows Task Scheduler can run the script at a fixed time each day. You can set it up in the GUI, but in PowerShell it takes five lines. Change the first line to the script's folder and paste the block into PowerShell (no admin rights needed).
$dir = "D:\gsc" # the folder that holds gsc_morning.py $py = (Get-Command python).Source $action = New-ScheduledTaskAction -Execute $py -Argument "gsc_morning.py" -WorkingDirectory $dir $trigger = New-ScheduledTaskTrigger -Daily -At 7:00 $settings = New-ScheduledTaskSettingsSet -StartWhenAvailable Register-ScheduledTask -TaskName "gsc_morning" -Action $action -Trigger $trigger -Settings $settings
-StartWhenAvailable means that if the PC is off at 7:00, the task runs the next time it starts. To check the task, run it once now and see whether report.md in today's folder gets a new timestamp. On my PC it finished in about 6 seconds with result 0 (success).
Start-ScheduledTask -TaskName "gsc_morning"
To remove it later, run this:
Unregister-ScheduledTask -TaskName "gsc_morning" -Confirm:$false
Let Claude Code sort the gaps
I still want to decide what to write myself. Going through each query to decide “this only needs a link” or “this is a typo” gets old fast, though, so I let Claude Code do that part by piping report.md into it.
cd D:\gsc # the folder that holds gsc_morning.py $OutputEncoding = [Text.Encoding]::UTF8 # pass non-English text to claude correctly in Windows PowerShell 5.1 $report = Get-ChildItem gsc-out -Directory | Sort-Object Name | Select-Object -Last 1 Get-Content (Join-Path $report.FullName "report.md") -Raw -Encoding UTF8 | claude -p "This is a Search Console summary for my blog. From section 1 (gaps), pick five queries that would make good new posts, skip any marked dedicated post, and give a one-line reason for each in a table."
claude -p asks Claude Code a single question and prints the answer. On my report it took about 30 seconds and returned a table of five queries, each with a one-line reason (in Japanese, the language my setup uses). It also listed the queries it skipped and why: one already had a dedicated post and only needed a better internal link, another would have competed with one of my own posts for the same search. It even merged a misspelled query into a related pick. Pretty much what I would have done by hand.
Some of those picks became real posts. “Offline scan won't start” (in Japanese) had 70 impressions in 28 days with no dedicated post, so I wrote a post on checking a Microsoft Defender Offline scan. “run unattended”, which only appeared in my English Tailscale post, is in the works.
Where I got stuck
1. The last few days looked like a crash
At first I pulled 28 days ending today. The last few days always had very few clicks, so every morning the script flagged a pile of “falling” pages. Search Console data takes 2 to 3 days to settle, and I was reading numbers that were still coming in. Ending the period 3 days ago fixed it.
2. The same post was counted twice
My theme's table of contents adds jump links such as #toc3, and Search Console reported those URLs as separate pages. Adding them up inflated the impressions. The script now cuts everything after # so they count as one post and keeps the larger number instead of the sum.
3. Posts I had just fixed kept coming back
After you change a title, it takes weeks for the numbers to show it. In the meantime the page still sits at position 6 to 12, so the same post showed up as a tune-up every morning, and I nearly edited the same post over and over. The script now reads the WordPress last-modified date and moves anything updated in the last 28 days to a “waiting” line.
| Smaller issue | Fix |
|---|---|
| Japanese queries have no spaces, so the “is there already a post?” check missed matches | Split words where the script changes between Latin, katakana, kanji and hiragana, and drop short particles |
| Query by page totals were lower than page totals | Google hides some rare queries for privacy, so risers and fallers come from a separate page-only request |
| CSV files showed garbled text in Excel | Write them as UTF-8 with a BOM (utf-8-sig) |
Ideas to take it further
- Put the Claude Code step into the scheduled task too. The first time I ran
claude -p, it warned that the sign-in would expire within a few days and suggested a long-lived token for unattended jobs. You would need to set that up first with the command below - Output the tune-up table only on Mondays
- On a platform other than WordPress, replace
wp_posts()with code that reads your posts from the sitemap
claude setup-token
Summary
Pulling query and page data from the Search Console API lets a short Python script list the queries that get impressions but no clicks, every morning, for free. The only setup is a service account key. Claude Code sorts the list, and I just pick what to write.
I wrote about drafting and posting with Claude Code in automating my blog from draft to WordPress, and about a daily news digest in a morning AI news briefing with Claude Cowork.


Comments