DB_JOB/작업파일/완료/광역_사이트맵/전북특별자치도/8.완주군/_ntest.py
hehihoho3 df16c98366 백업: DB수집 전체 스냅샷 (공공기관2 정리 전)
공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외.

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

38 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
import sys
from playwright.sync_api import sync_playwright
JS_BOARD_DETAIL='''() => {
const imgs=[...document.querySelectorAll('img')];
const real=imgs.filter(im=>/\/planweb\/upload\/.*\/board\//.test(im.src) && (im.clientWidth>=250||im.clientHeight>=250));
const att=[...document.querySelectorAll('a')].filter(a=>/\.(jpg|jpeg|png|gif)\b/i.test(a.textContent)).length;
return {realImgs:real.length, sizes:real.slice(0,3).map(i=>i.clientWidth+'x'+i.clientHeight), attach:att};
}'''
JS_FIRST_VIEWS='''() => [...document.querySelectorAll('a[href*="view.9is"]')].slice(0,3).map(a=>a.href)'''
JS_PAGE='''() => {
const bad=el=>{for(let n=el;n;n=n.parentElement){const c=(n.className&&n.className.baseVal!==undefined?n.className.baseVal:(n.className||''))+' '+(n.id||'');if(/header|footer|gnb|lnb|snb|nav|visual|main_|top_|quick|banner/i.test(c))return true;}return false;};
const imgs=[...document.querySelectorAll('img')];
const real=imgs.filter(im=>/\/planweb\/upload\//.test(im.src) && (im.clientWidth>=250||im.clientHeight>=250) && !bad(im));
const maps=[...document.querySelectorAll('iframe,embed,object')].filter(e=>/map|daum|kakao|google|vworld|roadview/i.test(e.src||e.data||''));
const pdf=[...document.querySelectorAll('iframe,embed,object,a')].filter(e=>/\.pdf/i.test(e.src||e.data||e.href||'')).length;
return {realImgs:real.length, sizes:real.slice(0,3).map(i=>i.clientWidth+'x'+i.clientHeight), maps:maps.length, pdf:pdf};
}'''
tests=[
('board','https://www.wanju.go.kr/planweb/board/list.9is?contentUid=ff8080818b024d8e018b274f41642af3&boardUid=ff8080818c0aecd1018c3334822b5364&categoryUid1=ff8080818c0aecd1018c33369f44539d'),
('page','https://www.wanju.go.kr/index.9is?contentUid=ff8080818b024d8e018b274f3'), # 일부러 잘린url - 대체
]
with sync_playwright() as p:
b=p.chromium.launch(); pg=b.new_page()
pg.set_default_timeout(15000)
# board
pg.goto(tests[0][1], wait_until='domcontentloaded'); pg.wait_for_timeout(1500)
views=pg.evaluate(JS_FIRST_VIEWS)
print('board views:',len(views))
hit=False
for v in views[:2]:
pg.goto(v, wait_until='domcontentloaded'); pg.wait_for_timeout(1200)
d=pg.evaluate(JS_BOARD_DETAIL); print(' detail',d)
if d['realImgs']>0 or d['attach']>0: hit=True
print('=> 축제board N=', '어문,이미지' if hit else '어문')
b.close()
print('OK')