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

26 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
import sys,io,urllib.request,ssl,re
from bs4 import BeautifulSoup
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def get(u):
try:
req=urllib.request.Request(u,headers={'User-Agent':'Mozilla/5.0'})
return urllib.request.urlopen(req,timeout=20,context=ctx).read().decode('utf-8','ignore')
except Exception as e: return 'ERR:%s'%e
SITES={
'옥천':'https://www.oc.go.kr/www/sub.do?key=121',
'음성':'https://www.eumseong.go.kr/www/sub.do?key=722',
'제천':'https://www.jecheon.go.kr/www/sitemap.do?key=553',
'청주':'https://www.cheongju.go.kr/www/sitemap.do?key=589',
'충주':'https://www.chungju.go.kr/www/sitemap.do?key=553',
}
for nm,u in SITES.items():
h=get(u)
if h.startswith('ERR'): print(nm,h[:60]); continue
s=BeautifulSoup(h,'html.parser')
d1=len(s.select('li.depth1_item')); d4=len(s.select('.depth4_item, .depth4'))
smbox=len(s.select('div.sitemap_box, #sitemap'))
sm2=len(s.select('ul.sm2depth')); h4=len(s.select('a.h4')); bu=len(s.select('ul.bu'))
print('%s len=%d | depth1_item=%d depth4=%d | sitemap_box=%d sm2depth=%d a.h4=%d ul.bu=%d'%(nm,len(h),d1,d4,smbox,sm2,h4,bu))