공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
1.3 KiB
Python
24 lines
1.3 KiB
Python
import sys, io, re, ssl, urllib.request
|
|
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 fetch(u):
|
|
return urllib.request.urlopen(urllib.request.Request(u, headers={'User-Agent':'Mozilla/5.0'}), context=ctx, timeout=25).read().decode('utf-8','replace')
|
|
B = 'https://www.jangsu.go.kr/index.jangsu?menuCd=DOM_000000'
|
|
|
|
def content_seg(h):
|
|
m = re.search(r'id="contents"(.*?)(?:<footer|id="footer|<!-- //CONTENTS)', h, re.S)
|
|
seg = m.group(1) if m else h
|
|
return re.sub(r'<script.*?</script>', '', seg, flags=re.S)
|
|
|
|
for nm, cd in [('정부24', '101002002000'), ('위택스', '101004004000'), ('민원실안내', '101001001000'),
|
|
('공지사항', '102001001000'), ('차량등록', '101005001000')]:
|
|
h = fetch(B + cd)
|
|
seg = content_seg(h)
|
|
ext = re.findall(r'href="(https?://(?!www\.jangsu\.go\.kr)[^"]+)"', seg)
|
|
ext = [e for e in ext if 'go.kr/index' not in e]
|
|
js = re.findall(r'(?:location\.href|window\.open)\s*\(?\s*["\']?(https?://[^"\' )]+)', seg)
|
|
bbs = len(re.findall(r'bbs_list', seg))
|
|
txt = re.sub(r'\s+', ' ', re.sub(r'<[^>]+>', ' ', seg)).strip()
|
|
print(f'[{nm}] bbs_list={bbs} 본문외부링크({len(ext)})={ext[:3]} JS={js[:2]}')
|
|
print(' txt[:120]:', txt[:120])
|