fix: Google 뉴스 RSS URL을 실제 기사 URL로 변환

수집 시 news.google.com/rss/articles/CBMi... 형태의 인코딩 URL을
리다이렉트 따라가서 실제 기사 URL로 저장. 출처 링크 클릭 시 원본 기사로 이동 가능.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
JOUNGWOOK KWON
2026-03-30 13:46:14 +09:00
parent d0cabc3f13
commit 2fcb2d353d

View File

@@ -402,6 +402,20 @@ def _extract_rss_image(entry) -> str:
return '' return ''
def _resolve_google_news_url(url: str) -> str:
"""Google 뉴스 RSS 인코딩 URL을 실제 기사 URL로 변환"""
if not url or 'news.google.com' not in url:
return url
try:
resp = requests.head(url, timeout=10, allow_redirects=True,
headers={'User-Agent': 'Mozilla/5.0'})
if resp.url and 'news.google.com' not in resp.url:
return resp.url
except Exception:
pass
return url
def collect_rss_feeds(sources_cfg: dict) -> list[dict]: def collect_rss_feeds(sources_cfg: dict) -> list[dict]:
"""설정된 RSS 피드 수집""" """설정된 RSS 피드 수집"""
items = [] items = []
@@ -428,7 +442,7 @@ def collect_rss_feeds(sources_cfg: dict) -> list[dict]:
'description': desc_text, 'description': desc_text,
'source': 'rss', 'source': 'rss',
'source_name': feed_cfg.get('name', ''), 'source_name': feed_cfg.get('name', ''),
'source_url': entry.get('link', ''), 'source_url': _resolve_google_news_url(entry.get('link', '')),
'published_at': pub_at, 'published_at': pub_at,
'search_demand_score': 8, 'search_demand_score': 8,
'topic_type': 'trending', 'topic_type': 'trending',