DB_JOB/작업파일/완료/광역_사이트맵/충청남도/9.서천군/_lnb2.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

17 lines
736 B
Python

# -*- coding: utf-8 -*-
import sys, urllib.request, ssl
sys.stdout.reconfigure(encoding='utf-8')
from bs4 import BeautifulSoup
ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
url='https://www.seocheon.go.kr/prog/rainStat/safe/sub07_05_01_01/list.do?siteCode=kor'
req=urllib.request.Request(url, headers={'User-Agent':'Mozilla/5.0'})
html=urllib.request.urlopen(req, context=ctx, timeout=30).read().decode('utf-8','replace')
soup=BeautifulSoup(html,'html.parser')
el = soup.select_one('#lnb')
# print nested list structure
import re
txt = ' / '.join(t.strip() for t in el.stripped_strings)
# show from 재난 onward
idx = txt.find('재난')
print(txt[idx-30:idx+400] if idx>=0 else txt[:600])