# -*- coding: utf-8 -*- # 청양 123+ L 재판정: 파일 K URL 패턴 기반(신뢰) + 크롤 시그널 보강 import openpyxl, json, io, sys, re from urllib.parse import urlparse sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8') F=r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\13.청양군\충청남도_청양군.xlsx' wb=openpyxl.load_workbook(F); ws=wb.active INTERNAL=('cheongyang.go.kr','cy.go.kr') def is_int(h): return any(x in (h or '') for x in INTERNAL) ver=json.load(open('_cy2_Lverdict.json',encoding='utf-8')) if False else {} rows=[] for r in range(123,ws.max_row+1): b=ws.cell(r,2).value if b is None: continue hl=ws.cell(r,11).hyperlink u=(hl.target if hl else ws.cell(r,11).value) or '' L=ws.cell(r,12).value lab=str(ws.cell(r,6).value or ws.cell(r,7).value or ws.cell(r,5).value or '')[:18] rows.append((r,b,lab,str(u),L)) def url_class(u): host=urlparse(u).netloc.lower() if u and not u.startswith('http'): return None,'rel' if u and not is_int(host): return '사이트','ext:'+host # 게시판 URL 패턴 if re.search(r'selectBoardList\.do|/cop/bbs/BBSMSTR|/bbs/.*list|selectBbsNttList', u): return '게시판','bbs' if re.search(r'/prog/.+/list\.do', u): return '게시판','prog-list' return None,'kor' # /kor/subNN.do 등은 크롤필요 cnt={} out=[] for r,b,lab,u,L in rows: c,why=url_class(u) out.append((r,b,lab,u,L,c,why)) flag = '' if (c is None or c==L) else (' <<