공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
17 lines
736 B
Python
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])
|