From 7323618f1d764212c97e4123480fe5a49c941735 Mon Sep 17 00:00:00 2001 From: Matt Li <16064851+Matt-V50@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:02:18 -0400 Subject: [PATCH] Refactor RSS fetching to use urllib instead of curl Replaced subprocess curl command with urllib for fetching RSS feeds. Docker environment doesn't support such un-installed package --- scripts/fetch_morning_news.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/fetch_morning_news.py b/scripts/fetch_morning_news.py index 2486ae53..45305f6b 100644 --- a/scripts/fetch_morning_news.py +++ b/scripts/fetch_morning_news.py @@ -48,13 +48,10 @@ def curl_rss(url, timeout=10): """用 curl 抓取 RSS""" try: - r = subprocess.run( - ['curl', '-s', '--max-time', str(timeout), '-L', - '-A', 'Mozilla/5.0 (compatible; MorningBrief/1.0)', - url], - capture_output=True, timeout=timeout+2 - ) - return r.stdout.decode('utf-8', errors='ignore') + from urllib.request import Request, urlopen + req = Request(url, headers={'User-Agent': 'Mozilla/5.0 (compatible; MorningBrief/1.0)'}) + response = urlopen(req, timeout=timeout) + return response.read().decode('utf-8', errors='ignore') except Exception: return ''