공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
23 lines
1.3 KiB
Python
23 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
import urllib.request, ssl, re, http.cookiejar
|
|
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
|
|
cj=http.cookiejar.CookieJar(); op=urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx),urllib.request.HTTPCookieProcessor(cj))
|
|
op.addheaders=[('User-Agent','Mozilla/5.0')]
|
|
def fixdom(u): return str(u).replace('https://new.igbf.kr','http://www.igbf.kr')
|
|
def g(u): return op.open(fixdom(u),timeout=20).read().decode('utf-8','replace')
|
|
IMG=re.compile(r'<img[^>]+src="([^"]+)"[^>]*>', re.I)
|
|
KOGLNAME=re.compile(r'(open(?:type|code)\d|opentype_\w+|ccl_\w+|kogl|nuri|gongu|공공누리)', re.I)
|
|
tests=[('우리민요반주(2유형)','http://www.igbf.kr/gugak_web/?sub_num=849'),
|
|
('보도자료(1유형,AI)','http://www.igbf.kr/gugak_web/?sub_num=764'),
|
|
('국악교육자료','http://www.igbf.kr/gugak_web/?sub_num=770'),
|
|
('편성표','http://www.igbf.kr/gugak_web/?sub_num=786'),
|
|
('국악방송소개','http://www.igbf.kr/gugak_web/?sub_num=754')]
|
|
for nm,u in tests:
|
|
h=g(u)
|
|
koglimgs=[s for s in IMG.findall(h) if KOGLNAME.search(s)]
|
|
print('%s:'%nm)
|
|
print(' kogl img:', koglimgs[:6])
|
|
# 보도자료는 게시판 -> 상세 확인
|
|
if 'board' in u or 'sub_num=764' in u:
|
|
pass
|