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:
@@ -402,6 +402,20 @@ def _extract_rss_image(entry) -> str:
|
||||
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]:
|
||||
"""설정된 RSS 피드 수집"""
|
||||
items = []
|
||||
@@ -428,7 +442,7 @@ def collect_rss_feeds(sources_cfg: dict) -> list[dict]:
|
||||
'description': desc_text,
|
||||
'source': 'rss',
|
||||
'source_name': feed_cfg.get('name', ''),
|
||||
'source_url': entry.get('link', ''),
|
||||
'source_url': _resolve_google_news_url(entry.get('link', '')),
|
||||
'published_at': pub_at,
|
||||
'search_demand_score': 8,
|
||||
'topic_type': 'trending',
|
||||
|
||||
Reference in New Issue
Block a user