DB_JOB/작업파일/_스크립트/_fetch_asan_kogl.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

30 lines
1.1 KiB
Python

import sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import urllib.request, ssl, re
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
hdr = {'User-Agent':'Mozilla/5.0'}
def fetch(url):
req = urllib.request.Request(url, headers=hdr)
with urllib.request.urlopen(req, context=ctx, timeout=20) as r:
return r.read().decode('utf-8', 'replace')
for no in (50, 55, 49, 365):
url = f'https://www.asan.go.kr/main/cms/?no={no}'
try:
html = fetch(url)
except Exception as e:
print(f'no={no} ERR {e}'); continue
print(f'\n===== no={no} len={len(html)} =====')
# find kogl / opentype marks
for m in re.finditer(r'<img[^>]*(?:opentype|kogl|opentype|gongu)[^>]*>', html, re.I):
print(' IMG:', m.group(0)[:200])
# find any link with kogl/opentype
for m in re.finditer(r'(opentype\d|kogl[^"\'<> ]*|img_opentype\d)', html, re.I):
print(' TOK:', m.group(0))
# title
t = re.search(r'<title>(.*?)</title>', html, re.S)
if t: print(' TITLE:', t.group(1).strip()[:80])