# -*- coding: utf-8 -*-
import openpyxl
from playwright.sync_api import sync_playwright
ws=openpyxl.load_workbook('한국중부발전.xlsx').active
# 시트 대분류(D) 순서
seen=[];prev=None
for r in range(3,ws.max_row+1):
    d=ws.cell(r,4).value
    if d and d!=prev: seen.append(d);
    if d: prev=d
print('시트 D 대분류:',seen)
# 현재 N값 확인
for r in (157,223):
    print(f'  r{r}: B={ws.cell(r,2).value} F={ws.cell(r,6).value or ws.cell(r,5).value} L={ws.cell(r,11).value} N={ws.cell(r,14).value!r}')
# 라이브 GNB 대분류
with sync_playwright() as p:
    b=p.chromium.launch();pg=b.new_page(ignore_https_errors=True)
    pg.goto('https://www.komipo.co.kr/kor/main.do',timeout=30000,wait_until='networkidle')
    pg.wait_for_timeout(1500)
    tops=pg.eval_on_selector_all('nav#gnb > ul > li > a, #gnb>ul>li>a, header nav>ul>li>a',
        'els=>els.map(e=>e.innerText.trim()).filter(Boolean)')
    print('라이브 GNB 대분류:',tops)
    b.close()
