DB_JOB/작업파일/공공기관2/10.한국지역난방공사/_pw2.py
hehihoho3 b0acd1e705 백업: 셀병합 정상화(D~J)+KDHC 옵션2/행높이17, 오늘(06-21) 제출 17곳 검수·압축
- 공공기관2/3 작업본 + 오늘 제출 17곳 D~J 카테고리 셀병합 정상화
- 한국지역난방공사 옵션2(고아셀 F98 수정)+전행 높이17
- 제출_프리랜서2_2026-06-21.zip 생성(17개 xlsx, 2,468행)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 13:21:26 +09:00

31 lines
1.4 KiB
Python

from playwright.sync_api import sync_playwright
targets={
'사회공헌위원회':"https://www.kdhc.co.kr/kdhc/bbs/B0000008/list.do?menuNo=200106",
'시민열냉방시설기준':"https://www.kdhc.co.kr/kdhc/cstmrCnter/arclngFclty/list.do?fcltyParntsSe=02&menuNo=200276",
'안전경영방침':"https://www.kdhc.co.kr/kdhc/bbs/B0000030/list.do?menuNo=200091",
'한난사보20-23':"https://www.kdhc.co.kr/kdhc/prCnter/cyclb/list.do?prTargetSe=2&menuNo=200127",
}
import io
with sync_playwright() as p:
b=p.chromium.launch(); pg=b.new_page()
res={}
for nm,u in targets.items():
pg.goto(u,wait_until='networkidle',timeout=30000)
# try main content selectors
txt=''
for sel in ['#contents','#content','.sub_contents','#container','.contents']:
el=pg.query_selector(sel)
if el:
txt=el.inner_text(); break
# strip menu noise: take last 400 chars of content region or search keywords
res[nm]=txt
b.close()
import re
for nm,txt in res.items():
has_empty='게시물이 없습니다' in txt or '등록된' in txt and '' in txt
# find the content after breadcrumb 'Home'
print('==',nm,'empty_msg=',('게시물이 없습니다' in txt))
# print middle/end portion
io.open(f'_ct_{nm}.txt','w',encoding='utf-8').write(txt)
print(' tail:', txt[-200:].replace(chr(10),' '))