DB_JOB/작업파일/완료/광역_사이트맵/충청북도/_probe_yd.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

20 lines
752 B
Python

# -*- coding: utf-8 -*-
import sys,io,urllib.request,ssl,re
from bs4 import BeautifulSoup
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
try: ctx.set_ciphers('DEFAULT@SECLEVEL=1')
except: pass
def get(u):
req=urllib.request.Request(u,headers={'User-Agent':'Mozilla/5.0'})
return urllib.request.urlopen(req,timeout=25,context=ctx).read().decode('utf-8','ignore')
h=get('https://www.yd21.go.kr/kr/html/guide/0701.html')
s=BeautifulSoup(h,'html.parser')
# sitemap container
sm=s.select_one('.sitemap') or s
dls=sm.find_all('dl')
print('dl수',len(dls))
for dl in dls[:2]:
print('--- dl ---')
print(re.sub(r'\s+',' ',str(dl))[:900])