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(url_safety): share fetch_page's header defaults and drop Accept-Language
Agrici Daniel29910912906f
diff --git a/scripts/fetch_page.py b/scripts/fetch_page.pyindex fb8826f..f6868b3 100755--- a/scripts/fetch_page.py+++ b/scripts/fetch_page.py@@ -30,12 +30,18 @@ except ImportError:_SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))if _SCRIPTS_DIR not in sys.path:sys.path.insert(0, _SCRIPTS_DIR)-from url_safety import URLSafetyError, safe_requests_session, validate_url_strict # noqa: E402--DEFAULT_USER_AGENT = (- "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "- "(KHTML, like Gecko) Chrome/150.0.7871.114 Safari/537.36 ClaudeSEO/2.0"+from url_safety import ( # noqa: E402+ DEFAULT_REQUEST_HEADERS,+ URLSafetyError,+ safe_requests_session,+ validate_url_strict,)+from url_safety import DEFAULT_USER_AGENT as DEFAULT_USER_AGENT # noqa: E402,F401++# DEFAULT_USER_AGENT and the header block now live in url_safety, the lower+# layer that both this script and the safe_requests_* helpers go through, so+# there is one place to change them. The name is re-exported above because+# fetch_page.DEFAULT_USER_AGENT was the public spelling before v2.3.0.# Googlebot UA for prerender/dynamic rendering detection.# Prerender services (Prerender.io, Rendertron) serve fully rendered HTML to@@ -46,13 +52,10 @@ GOOGLEBOT_USER_AGENT = ("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")-DEFAULT_HEADERS = {- "User-Agent": DEFAULT_USER_AGENT,- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",- "Accept-Language": "en-US,en;q=0.5",- "Accept-Encoding": "gzip, deflate",- "Connection": "keep-alive",-}+# One source of truth with the safe_requests_* helpers. Accept-Language is+# absent by design: announcing en-US makes multi-locale sites serve their+# English variant, which corrupts hreflang and international audits.+DEFAULT_HEADERS = dict(DEFAULT_REQUEST_HEADERS)_CONTENT_TYPE_CHARSET_RE = re.compile(r"charset\s*=\s*['\"]?([^;,'\"\s>]+)", re.IGNORECASE)_META_CHARSET_RE = re.compile(diff --git a/scripts/url_safety.py b/scripts/url_safety.pyindex 077bc07..fb2a5f4 100644--- a/scripts/url_safety.py+++ b/scripts/url_safety.py@@ -99,6 +99,8 @@ __all__ = ["safe_requests_head","safe_requests_session","make_safe_playwright_route_handler",+ "DEFAULT_USER_AGENT",+ "DEFAULT_REQUEST_HEADERS",]@@ -553,23 +555,33 @@ def _pin_dns(_dns_patch_lock.release()-# Default request headers, mirroring the browser-like defaults fetch_page.py-# has used since v1.2.1 (issue #9). Without them ``requests`` announces itself-# as ``User-Agent: python-requests/x.y.z`` with no Accept-Language, which many-# managed WAFs and CDNs answer with 403/406, and which SSR frameworks answer-# with the empty client-side shell. Callers do not see an exception in that-# case, they analyse the error page or the shell as if it were the real-# document. Any header here can be overridden by passing ``headers=``.+# The browser-like default User-Agent for every raw-HTTP fetch in claude-seo.+# ``fetch_page.py`` has carried these defaults since v1.2.1 (issue #9); they+# live here now because ``url_safety`` is the lower layer, so this module is+# the one place to change them. ``fetch_page.py`` imports them back.+DEFAULT_USER_AGENT = (+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "+ "(KHTML, like Gecko) Chrome/150.0.7871.114 Safari/537.36 ClaudeSEO/2.0"+)++# Without these, ``requests`` announces itself as+# ``User-Agent: python-requests/x.y.z``, which many managed WAFs and CDNs+# answer with 403/406 and SSR frameworks answer with the empty client-side+# shell. Callers do not see an exception in that case, they analyse the error+# page or the shell as if it were the real document.+#+# Accept-Language is deliberately absent. Announcing ``en-US`` makes a+# multi-locale site serve its English variant, which silently corrupts every+# hreflang, international, and localized-content audit. A caller that wants a+# specific locale passes it in ``headers=``; anything else lets the site+# choose, which is what an auditor wants to observe.+#+# Any header here can be overridden by passing ``headers=``.DEFAULT_REQUEST_HEADERS = {- "User-Agent": (- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 "- "(KHTML, like Gecko) Chrome/150.0.7871.115 Safari/537.36 ClaudeSEO/2.0"- ),- "Accept": (- "text/html,application/xhtml+xml,application/xml;q=0.9,"- "image/avif,image/webp,*/*;q=0.8"- ),- "Accept-Language": "en-US,en;q=0.9",+ "User-Agent": DEFAULT_USER_AGENT,+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",+ "Accept-Encoding": "gzip, deflate",+ "Connection": "keep-alive",}diff --git a/tests/test_url_safety.py b/tests/test_url_safety.pyindex 46a2d2e..e26d45c 100644--- a/tests/test_url_safety.py+++ b/tests/test_url_safety.py@@ -360,7 +360,27 @@ def test_default_headers_are_browser_like() -> None:headers = url_safety.DEFAULT_REQUEST_HEADERSassert "python-requests" not in headers["User-Agent"]assert headers["User-Agent"].startswith("Mozilla/5.0")- assert "Accept-Language" in headers+ assert "Accept" in headers+++def test_default_headers_are_the_same_object_fetch_page_uses() -> None:+ """One source of truth: fetch_page.py's raw-HTTP defaults are url_safety's,+ so the two fetch paths cannot drift into announcing different clients."""+ import fetch_page # noqa: WPS433++ assert fetch_page.DEFAULT_HEADERS == url_safety.DEFAULT_REQUEST_HEADERS+ assert fetch_page.DEFAULT_USER_AGENT == url_safety.DEFAULT_USER_AGENT+ assert (+ url_safety.DEFAULT_REQUEST_HEADERS["User-Agent"]+ == url_safety.DEFAULT_USER_AGENT+ )+++def test_default_headers_do_not_announce_a_language() -> None:+ """Announcing en-US makes a multi-locale site serve its English variant,+ which silently corrupts every hreflang and international audit."""+ assert "Accept-Language" not in url_safety.DEFAULT_REQUEST_HEADERS+ assert "Accept-Language" not in url_safety._with_default_headers({})["headers"]def test_with_default_headers_fills_unset_headers() -> None:@@ -379,9 +399,42 @@ def test_with_default_headers_lets_caller_override() -> None:)["headers"]assert merged["User-Agent"] == "Googlebot/2.1"# Headers the caller did not set are still filled in.- assert merged["Accept-Language"] == (- url_safety.DEFAULT_REQUEST_HEADERS["Accept-Language"]- )+ assert merged["Accept"] == url_safety.DEFAULT_REQUEST_HEADERS["Accept"]+++def _capture_safe_get_headers(**kwargs) -> dict:+ """Run safe_requests_get with validation and pinning stubbed out, and+ return the headers mapping that reached requests.get."""+ @contextmanager+ def fake_pin(hostname: str, pinned_ip: str, port: int, exempt_hosts=frozenset()):+ yield++ with patch.object(+ url_safety,+ "validate_url_strict",+ return_value=("https://safe.example/", "1.1.1.1"),+ ), patch.object(+ url_safety, "_pin_dns", side_effect=fake_pin+ ), patch.object(+ url_safety, "_validated_proxy_hosts", return_value=frozenset()+ ), patch.object(+ url_safety.requests, "get", return_value=SimpleNamespace(status_code=200)+ ) as request_get:+ url_safety.safe_requests_get("https://safe.example/", **kwargs)+ return request_get.call_args.kwargs["headers"]+++def test_safe_requests_get_sends_no_accept_language_by_default() -> None:+ headers = _capture_safe_get_headers()+ assert "Accept-Language" not in headers+ assert headers["User-Agent"] == url_safety.DEFAULT_USER_AGENT+++def test_safe_requests_get_preserves_a_caller_supplied_accept_language() -> None:+ headers = _capture_safe_get_headers(headers={"Accept-Language": "de-DE,de;q=0.9"})+ assert headers["Accept-Language"] == "de-DE,de;q=0.9"+ # The rest of the defaults are still filled in.+ assert headers["Accept"] == url_safety.DEFAULT_REQUEST_HEADERS["Accept"]def test_with_default_headers_preserves_other_kwargs_and_constant() -> None: