import sys, io, json sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') import openpyxl, urllib.request, ssl, re from concurrent.futures import ThreadPoolExecutor P = r'D:\01.프로젝트\DB수집\작업파일\광역_사이트맵\충청남도\10.아산시\충청남도_아산시.xlsx' wb = openpyxl.load_workbook(P); ws = wb.active 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=25) as r: return r.read().decode('utf-8','replace') targets=[] for r in range(37, ws.max_row+1): k=ws[f'K{r}'].value; l=ws[f'L{r}'].value; o=ws[f'O{r}'].value if not k or 'asan.go.kr' not in str(k) or l=='사이트': continue targets.append((r,str(k),l,o)) def work(t): r,k,l,o=t try: html=fetch(k) except Exception as e: return (r,k,l,o,'ERR',None,None) mt=re.search(r'img_opentype_(\d)\.gif', html) otype=mt.group(1) if mt else None # broad: any