import requests EM_BASE = "https://datacenter-web.eastmoney.com/api/data/v1/get" headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "Referer": "https://data.eastmoney.com/", "Accept": "application/json", } # 已知可能的龙虎榜报表名变体 report_names = [ "RPT_LHB_ALL_STOCKS", "RPT_LHB_ALL", # 龙虎榜概览 "RPT_LHB_STOCK", # 个股龙虎榜 "RPT_LHB_BILLBOARD", # 可能的英文名 "RPT_STOCK_LHB", # 倒装 "LHB_ALL_STOCKS", # 无前缀 ] for report in report_names: params = { "reportName": report, "columns": "ALL", "filter": "(TRADE_DATE='2026-09-12')", "pageNumber": 1, "pageSize": 2, "source": "WEB", "client": "WEB", } try: r = requests.get(EM_BASE, params=params, headers=headers, timeout=10) resp = r.json() if resp.get("success"): result = resp.get("result") or {} data = result.get("data") or [] print(f"[OK] {report}: {len(data)} rows, keys={list(data[0].keys())[:5] if data else 'empty'}") else: print(f"[FAIL] {report}: {resp.get('message', 'unknown error')}") except Exception as e: print(f"[ERR] {report}: {e}")