fix: use direct RDAP servers instead of rdap.org (blocked by Cloudflare)
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

Maps TLD to native RDAP server: .pl → rdap.dns.pl, .com/.net → Verisign,
.eu → rdap.eu, .de → denic.de. Adds User-Agent header.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-11 06:14:00 +01:00
parent 3690b4d77e
commit b818423669

View File

@ -387,7 +387,7 @@ def admin_seo_detail(company_id):
except Exception:
pass
# WHOIS domain expiry lookup
# WHOIS domain expiry lookup via RDAP
domain_info = {}
if analysis and company.website:
try:
@ -396,20 +396,34 @@ def admin_seo_detail(company_id):
domain_match = re.search(r'https?://(?:www\.)?([^/]+)', company.website)
if domain_match:
domain = domain_match.group(1)
resp = req.get(
f'https://rdap.org/domain/{domain}',
timeout=5,
headers={'Accept': 'application/rdap+json'}
)
# Map TLD to direct RDAP server (bypass rdap.org Cloudflare)
tld = domain.rsplit('.', 1)[-1].lower()
rdap_servers = {
'pl': 'https://rdap.dns.pl',
'com': 'https://rdap.verisign.com/com/v1',
'net': 'https://rdap.verisign.com/net/v1',
'org': 'https://rdap.org/domain', # fallback
'eu': 'https://rdap.eu/domain',
'de': 'https://rdap.denic.de',
}
rdap_base = rdap_servers.get(tld, f'https://rdap.org')
rdap_url = f'{rdap_base}/domain/{domain}'
resp = req.get(rdap_url, timeout=5, headers={
'Accept': 'application/rdap+json',
'User-Agent': 'NordaBiz-SEO-Audit/1.0'
})
if resp.status_code == 200:
rdap = resp.json()
for event in rdap.get('events', []):
if event.get('eventAction') == 'expiration':
domain_info['expires'] = event.get('eventDate', '')[:10]
elif event.get('eventAction') == 'registration':
domain_info['registered'] = event.get('eventDate', '')[:10]
elif event.get('eventAction') == 'last changed':
domain_info['updated'] = event.get('eventDate', '')[:10]
action = event.get('eventAction')
date_str = event.get('eventDate', '')[:10]
if action == 'expiration':
domain_info['expires'] = date_str
elif action == 'registration':
domain_info['registered'] = date_str
elif action == 'last changed':
domain_info['updated'] = date_str
# Registrar from entities
for entity in rdap.get('entities', []):
if 'registrar' in entity.get('roles', []):