Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.
fix(backlinks): discover the newest Common Crawl graph from graphinfo.json
pucilpet54b741f21a42
diff --git a/scripts/commoncrawl_graph.py b/scripts/commoncrawl_graph.pyindex 14ec40c..aca25a4 100644--- a/scripts/commoncrawl_graph.py+++ b/scripts/commoncrawl_graph.py@@ -7,13 +7,13 @@ extract PageRank, harmonic centrality, crawl/ranking presence, and host counts.No API key needed (public data).Data source: s3://commoncrawl/projects/hyperlinkgraph/-Releases: Quarterly (cc-main-YYYY-mon-mon-mon)+Releases: Monthly, each built from three crawls (cc-main-YYYY-mon-mon-mon)Usage:python commoncrawl_graph.py example.com --jsonpython commoncrawl_graph.py example.com --update --jsonpython commoncrawl_graph.py --info --json- python commoncrawl_graph.py example.com --release cc-main-2026-jan-feb-mar --json+ python commoncrawl_graph.py example.com --release cc-main-2026-jul-aug-sep --json"""import argparse@@ -42,10 +42,17 @@ except ImportError:# Common Crawl web graph base URL (HTTP access to S3 bucket)CC_GRAPH_BASE = "https://data.commoncrawl.org/projects/hyperlinkgraph"-# Known recent releases (newest first).-# Update periodically: check https://commoncrawl.github.io/cc-webgraph-statistics/-# Naming convention: cc-main-YYYY-mon-mon-mon (quarterly, lowercase month abbreviations)+# Common Crawl's own list of published web graphs, newest first. Read at+# run time so a new release is picked up without editing this file.+CC_GRAPHINFO_URL = "https://index.commoncrawl.org/graphinfo.json"++# Fallback when graphinfo.json cannot be read (newest first).+# Naming convention: cc-main-YYYY-mon-mon-mon (lowercase month abbreviations).+# Common Crawl now publishes a graph every month from three consecutive+# crawls; this fallback keeps one release per quarter.KNOWN_RELEASES = [+ "cc-main-2026-jul-aug-sep",+ "cc-main-2026-apr-may-jun","cc-main-2026-jan-feb-mar","cc-main-2025-oct-nov-dec","cc-main-2025-jul-aug-sep",@@ -74,16 +81,43 @@ def _safe_float(s: str) -> Optional[float]:return None+def _published_releases(limit: int = 3) -> list:+ """Return up to `limit` release ids from graphinfo.json, newest first.++ Returns [] on any network or format problem, so callers fall back to+ KNOWN_RELEASES. Ids that fail _RELEASE_RE are skipped, because a release+ id is interpolated into a download URL and a cache path.+ """+ try:+ resp = requests.get(CC_GRAPHINFO_URL, timeout=10)+ resp.raise_for_status()+ graphs = resp.json()+ except (requests.exceptions.RequestException, ValueError):+ return []+ if not isinstance(graphs, list):+ return []+ releases = []+ for graph in graphs:+ release = graph.get("id") if isinstance(graph, dict) else None+ if isinstance(release, str) and _RELEASE_RE.match(release):+ releases.append(release)+ if len(releases) >= limit:+ break+ return releases++def _get_latest_release() -> Optional[str]:"""Discover the latest available CC web graph release.- Tries known releases in order, returns the first one that exists.+ Asks Common Crawl's graphinfo.json for the newest graph first, then+ falls back to KNOWN_RELEASES. Returns the first release whose domain+ vertices file exists.Returns:- Release name (e.g., 'cc-main-2026-jan-feb-mar') or None.+ Release name (e.g., 'cc-main-2026-jul-aug-sep') or None."""- for release in KNOWN_RELEASES:+ for release in _published_releases() + KNOWN_RELEASES:url = _graph_file_url(release, VERTICES_SUFFIX)try:resp = requests.head(url, timeout=10, allow_redirects=True)diff --git a/tests/test_commoncrawl_graph.py b/tests/test_commoncrawl_graph.pyindex 7c04661..fcf0ba7 100644--- a/tests/test_commoncrawl_graph.py+++ b/tests/test_commoncrawl_graph.py@@ -86,3 +86,62 @@ def test_release_pattern_accepts_real_release_ids(release):)def test_release_pattern_rejects_traversal_and_junk(release):assert not ccg._RELEASE_RE.match(release)+++# ---------------------------------------------------------------------------+# latest-release discovery (graphinfo.json first, KNOWN_RELEASES fallback)+# ---------------------------------------------------------------------------+++class _Resp:+ def __init__(self, status=200, payload=None, exc=None):+ self.status_code = status+ self._payload = payload+ self._exc = exc++ def raise_for_status(self):+ if self.status_code >= 400:+ raise ccg.requests.exceptions.HTTPError(str(self.status_code))++ def json(self):+ if self._exc:+ raise self._exc+ return self._payload+++def _head_ok_for(existing):+ def head(url, **_kw):+ return _Resp(200 if any(f"/{r}/domain/" in url for r in existing) else 404)+ return head+++def test_latest_release_prefers_graphinfo(monkeypatch):+ graphs = [{"id": "cc-main-2099-jan-feb-mar"}, {"id": ccg.KNOWN_RELEASES[0]}]+ monkeypatch.setattr(ccg.requests, "get", lambda url, **kw: _Resp(payload=graphs))+ monkeypatch.setattr(ccg.requests, "head", _head_ok_for({"cc-main-2099-jan-feb-mar"}))+ assert ccg._get_latest_release() == "cc-main-2099-jan-feb-mar"+++def test_latest_release_skips_unsafe_graphinfo_ids(monkeypatch):+ graphs = [{"id": "../../etc/passwd"}, {"id": 42}, "junk", {"id": "cc-main-2099-jan-feb-mar"}]+ monkeypatch.setattr(ccg.requests, "get", lambda url, **kw: _Resp(payload=graphs))+ assert ccg._published_releases() == ["cc-main-2099-jan-feb-mar"]+++ "response",+ [_Resp(status=503), _Resp(payload={"not": "a list"}), _Resp(exc=ValueError("bad json"))],+)+def test_latest_release_falls_back_to_known_releases(monkeypatch, response):+ monkeypatch.setattr(ccg.requests, "get", lambda url, **kw: response)+ monkeypatch.setattr(ccg.requests, "head", _head_ok_for(set(ccg.KNOWN_RELEASES)))+ assert ccg._get_latest_release() == ccg.KNOWN_RELEASES[0]+++def test_latest_release_falls_back_when_graphinfo_unreachable(monkeypatch):+ def boom(url, **kw):+ raise ccg.requests.exceptions.ConnectionError("offline")++ monkeypatch.setattr(ccg.requests, "get", boom)+ monkeypatch.setattr(ccg.requests, "head", _head_ok_for({ccg.KNOWN_RELEASES[1]}))+ assert ccg._get_latest_release() == ccg.KNOWN_RELEASES[1]