# services/motie_vip_parser.py

from bs4 import BeautifulSoup
from utils.fetcher import fetch_html

def get_motie_departments():
    url = "https://www.motie.go.kr/kor/26/headquarters"
    html = fetch_html(url)
    if not html:
        return []

    soup = BeautifulSoup(html, "html.parser")
    options = soup.select("a[onclick*='headquarters.jsSearchOrgan']")
    
    departments = []

    for a in options:
        text = a.get_text(strip=True)
        if text:
            departments.append(text)

    # 첫 번째 항목은 "전체"일 수 있으니 제외
    return departments[1:] if departments and departments[0] == "전체" else departments
