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']*(?: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'