DB_JOB/작업파일/공공기관2/14.한국청소년정책연구원/_chk_cand.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

32 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
import sys,io
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
from playwright.sync_api import sync_playwright
C={
'r8_CI':"https://www.nypi.re.kr/board?menuKey=36AnOd5WEI&bbsId=BOARD00043",
'r17_정기간행물':"https://www.nypi.re.kr/board?menuKey=a2cArE1kDq&bbsId=BOARD00044",
'r31_리플릿':"https://www.nypi.re.kr/board?menuKey=KHNEsLyaI5&bbsId=BOARD00013",
'r18_발간물안내':"https://www.nypi.re.kr/lib/10450/custom/1063002/academic",
'r19_데이터아카이브':"https://www.nypi.re.kr/archive/",
}
with sync_playwright() as p:
br=p.chromium.launch(headless=True); ctx=br.new_context(ignore_https_errors=True,viewport={'width':1280,'height':2000})
for nm,u in C.items():
pg=ctx.new_page()
try:
pg.goto(u,wait_until='networkidle',timeout=35000); pg.wait_for_timeout(1500)
# 본문 콘텐츠 이미지(원본>=200x150, 장식파일명 제외)
r=pg.evaluate(r"""()=>{
const dec=/logo|icon|btn|mark_|webwatch|eprivacy|sns|footer|header|banner|bg_|sprite|blank|no_img|arrow|family/i;
let cont=document.querySelector('#contents,.contents,#content,.board_view,.view_content,.sub_content')||document.body;
let imgs=[...cont.querySelectorAll('img')].filter(im=>im.naturalWidth>=200&&im.naturalHeight>=150&&!dec.test(im.src)).map(im=>im.src.split('/').pop().slice(0,30)+`(${im.naturalWidth}x${im.naturalHeight})`);
let vids=[...cont.querySelectorAll('video,iframe[src*=\"youtube\"]')].length;
let host=location.host;
return {host,n_img:imgs.length,imgs:imgs.slice(0,6),vids, title:document.title.slice(0,40)};
}""")
print(nm,'::',r)
except Exception as e:
print(nm,'ERR',str(e)[:50])
pg.close()
br.close()