From cb098026eb7c9ed866b98cabad90709e6e782074 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Sat, 2 May 2026 18:58:07 +0800 Subject: [PATCH] auto-sync: 2026-05-02 18:58:07 --- data_platform/updater.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data_platform/updater.py b/data_platform/updater.py index 65c239d3..818c9b42 100644 --- a/data_platform/updater.py +++ b/data_platform/updater.py @@ -81,13 +81,15 @@ def fetch_incremental(code: str, start_date: str, end_date: str): # 2. 腾讯K线API try: + import urllib.request, json prefix = 'sh' if code.startswith(('6', '5', '1')) else 'sz' tq = f"{prefix}{code}" days = (pd.Timestamp(end_date) - pd.Timestamp(start_date)).days + 10 url = f"https://web.ifzq.gtimg.cn/appstock/app/fqkline/get?param={tq},day,,{days}," - import urllib.request, json + # 用无代理opener避免akshare代理污染 + opener = urllib.request.build_opener(urllib.request.ProxyHandler({})) req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) - with urllib.request.urlopen(req, timeout=10) as r: + with opener.open(req, timeout=10) as r: data = json.loads(r.read()) klines = data.get("data", {}).get(tq, {}).get("day", []) if not klines: