[verified] Generalize BOT regional header detection (BE year 25XX); only enable regions with real data
- header month-cell detection now matches any 4-digit BE year (25XX) not just 256X - northeast reportID 955 disabled: returns 0.0 BE-2570 placeholder page, no real data yet (documented) - north 954 stays enabled (live idx 100.3); tests + full suite 152 OK
This commit is contained in:
@@ -32,7 +32,11 @@ _USER_AGENT = (
|
||||
)
|
||||
_BASE_URL = "https://app.bot.or.th/BTWS_STAT/statistics/ReportPage.aspx?reportID="
|
||||
|
||||
# Default mapping of BOT regions; extend as other reportIDs are confirmed.
|
||||
# Default mapping of BOT regions (BTWS_STAT regional consumption reports).
|
||||
# Only regions with REAL published values are enabled. north (RG_NR_042, 954)
|
||||
# is confirmed live (idx 100.3). northeast (RG_NE_044, 955) currently returns a
|
||||
# 0.0 placeholder (BE 2570 forecast page, no real data yet) so it is NOT enabled
|
||||
# until BOT publishes real values. south/central reportIDs pending confirmation.
|
||||
REGION_REPORT_IDS: dict[str, int] = {
|
||||
"north": 954,
|
||||
}
|
||||
@@ -112,9 +116,9 @@ def parse_bot_regional_html(html_text: str) -> dict:
|
||||
if not cells:
|
||||
continue
|
||||
# header row: month labels (e.g. 'มิ.ย. 2569 p') — keep only cells
|
||||
# whose text carries a Thai month + Buddhist year (256X).
|
||||
if "256" in " ".join(cells) and not re.search(r"\d\.\d", " ".join(cells)):
|
||||
# keep only cells carrying a 4-digit BE year (256X) — drops
|
||||
# carrying a 4-digit BE year (25XX, may be 2569/2570/...).
|
||||
if re.search(r"25\d\d", " ".join(cells)) and not re.search(r"\d\.\d", " ".join(cells)):
|
||||
# keep only cells carrying a 4-digit BE year (25XX) — drops
|
||||
# column titles like 'ลำดับ' / 'รายการ'.
|
||||
month_cells = [c for c in cells if re.search(r"25\d\d", c)]
|
||||
if month_cells:
|
||||
|
||||
Reference in New Issue
Block a user