공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26 lines
1.2 KiB
Python
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))
|