DB_JOB/작업파일/완료/광역_사이트맵/충청북도/_cy2_inspect.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.1 KiB
Python

# -*- coding: utf-8 -*-
import io,sys,time
from playwright.sync_api import sync_playwright
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
URLS={
'청양홍보책자(prog eBook)':'https://www.cheongyang.go.kr/prog/eBook/webzine/kor/sub04_01_04/list.do',
'군민지원사업(prog subscribe)':'https://www.cheongyang.go.kr/prog/subscribe/kor/sub04_01_07/list.do',
'고시공고(kor .do)':'https://www.cheongyang.go.kr/kor/sub04_01_06_01_01.do',
'청양군보(kor .do)':'https://www.cheongyang.go.kr/kor/sub04_02_05.do',
'2022전국대회(kor .do)':'https://www.cheongyang.go.kr/kor/sub04_05_08.do',
'적극행정새소식(kor .do)':'https://www.cheongyang.go.kr/kor/sub04_07_09.do',
}
JS=r'''()=>{
const t=document.body?document.body.innerText:'';
const tot=/총\s*게시물|총\s*\d+\s*건|게시물\s*:?\s*\d+|Total/.exec(t);
const tables=[...document.querySelectorAll('table')].map(x=>x.className||'(noclass)');
const lists=[...document.querySelectorAll('ul,ol')].filter(x=>/board|bbs|list|gallery|photo/i.test(x.className||'')).map(x=>x.className);
const views=[...document.querySelectorAll('a')].filter(a=>/view\.do|selectBoardArticle|nttId=|articleNo=|seq=|idx=|BoardArticle|dataSid|notiNo|bbsSeq/i.test(a.href||'')).length;
const dates=(t.match(/20\d\d[-.]\d\d?[-.]\d\d?/g)||[]).length;
const ifr=[...document.querySelectorAll('iframe')].map(f=>f.src).slice(0,3);
return {tot:tot?tot[0]:null, tables:tables.slice(0,6), lists:lists.slice(0,4), views, dates, ifr};
}'''
with sync_playwright() as p:
b=p.chromium.launch(); pg=b.new_page(viewport={'width':1280,'height':2200}); pg.set_default_timeout(25000)
for name,u in URLS.items():
try:
pg.goto(u,wait_until='networkidle',timeout=25000); pg.wait_for_timeout(1500)
d=pg.evaluate(JS)
print('\n###',name)
print(' final:',pg.url)
print(' 총건수:',d['tot'],'| view링크:',d['views'],'| 날짜수:',d['dates'])
print(' tables:',d['tables'])
print(' lists:',d['lists'])
print(' iframe:',d['ifr'])
except Exception as e:
print('\n###',name,'ERR',str(e)[:60])
b.close()