migrate: last 4 JSON files — live_prices, market, mtf_cache, capital_flow → DB

This commit is contained in:
知微
2026-07-03 13:44:10 +08:00
parent 7cc0ea0ef3
commit bb9b3922c9
27 changed files with 2064 additions and 1256 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Test if steady 5s interval avoids rate limit"""
import urllib.request, json, time
UA = 'Mozilla/5.0'
codes = ['00700', '01888', '00981']
for i, code in enumerate(codes):
url = f"https://push2.eastmoney.com/api/qt/stock/get?secid=116.{code}&fields=f43,f170&fltt=2"
start = time.time()
try:
req = urllib.request.Request(url, headers={"User-Agent": UA})
with urllib.request.urlopen(req, timeout=5) as r:
resp = json.loads(r.read().decode("utf-8"))
elapsed = time.time() - start
price = resp.get('data', {}).get('f43', '?')
print(f"#{i+1} {code}: OK in {elapsed:.1f}s, price={price}")
except Exception as e:
elapsed = time.time() - start
print(f"#{i+1} {code}: FAIL in {elapsed:.1f}s — {type(e).__name__}")
break
if i < len(codes) - 1:
time.sleep(5)