DB_JOB/작업파일/완료/공공기관/_gugak_kogl_probe3.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

24 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')
def koglblock(h):
i=h.lower().find('kogl')
if i<0: return None
return re.sub(r'\s+',' ', re.sub(r'<[^>]+>',' ', h[max(0,i-400):i+400]))
for nm,u in [('우리민요반주(2유형)','http://www.igbf.kr/gugak_web/?sub_num=849'),
('편성표','http://www.igbf.kr/gugak_web/?sub_num=786'),
('국악교육자료','http://www.igbf.kr/gugak_web/?sub_num=770'),
('국악방송소개','http://www.igbf.kr/gugak_web/?sub_num=754')]:
h=g(u)
has='kogl' in h.lower()
# kogl img src
koglimg=re.findall(r'<img[^>]+src="([^"]*kogl[^"]*)"', h, re.I)
# 조건 텍스트
cond=re.findall(r'출처표시(?:-상업적이용금지)?(?:-변경금지)?', h)
print('%s: kogl요소=%s img=%s 조건텍스트=%s'%(nm, has, koglimg[:3], set(cond)))
if has: print(' blk:', koglblock(h)[:200])