fix(gsc): Support domain property format (sc-domain:) in Search Console
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
The site was added as a domain property in GSC, not URL prefix. _normalize_site_url() now tries sc-domain:example.com variant. Also added ctr/position to top_queries for template display. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
53e4352c40
commit
8fd81e3a16
@ -67,10 +67,20 @@ class SearchConsoleService:
|
|||||||
else:
|
else:
|
||||||
variants.append(v.replace('://', '://www.'))
|
variants.append(v.replace('://', '://www.'))
|
||||||
|
|
||||||
|
# Domain property variant (sc-domain:example.com)
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
parsed = urlparse(url)
|
||||||
|
domain = parsed.hostname or ''
|
||||||
|
if domain.startswith('www.'):
|
||||||
|
domain = domain[4:]
|
||||||
|
if domain:
|
||||||
|
variants.append(f'sc-domain:{domain}')
|
||||||
|
|
||||||
for v in variants:
|
for v in variants:
|
||||||
if v in site_urls:
|
if v in site_urls:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
logger.debug(f"No match for {url}. Available sites: {site_urls}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_search_analytics(self, site_url: str, days: int = 28) -> Dict:
|
def get_search_analytics(self, site_url: str, days: int = 28) -> Dict:
|
||||||
@ -122,7 +132,13 @@ class SearchConsoleService:
|
|||||||
)
|
)
|
||||||
if resp_q.status_code == 200:
|
if resp_q.status_code == 200:
|
||||||
result['top_queries'] = [
|
result['top_queries'] = [
|
||||||
{'query': r['keys'][0], 'clicks': r.get('clicks', 0), 'impressions': r.get('impressions', 0)}
|
{
|
||||||
|
'query': r['keys'][0],
|
||||||
|
'clicks': r.get('clicks', 0),
|
||||||
|
'impressions': r.get('impressions', 0),
|
||||||
|
'ctr': round(r.get('ctr', 0) * 100, 2),
|
||||||
|
'position': round(r.get('position', 0), 1),
|
||||||
|
}
|
||||||
for r in resp_q.json().get('rows', [])
|
for r in resp_q.json().get('rows', [])
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user