공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
28 lines
1.4 KiB
Python
28 lines
1.4 KiB
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
|
|
|
|
def lnb(url, tag):
|
|
try:
|
|
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')
|
|
print(f'\n##### {tag}: {url}')
|
|
# title / breadcrumb
|
|
for sel in ['.lnb', '#lnb', '.snb', '#snb', '.left_menu', '.lftMenu', '.sub_lnb', '.location', '.breadcrumb', '.path']:
|
|
for el in soup.select(sel):
|
|
txt = ' / '.join(t.strip() for t in el.stripped_strings)
|
|
if txt:
|
|
print(f' [{sel}] {txt[:300]}')
|
|
break
|
|
except Exception as e:
|
|
print(f'\n##### {tag}: {url}\n ERR {e}')
|
|
|
|
# 군민참여 신고 그룹 (내부 페이지)
|
|
lnb('https://www.seocheon.go.kr/kor/sub03_02_08_01.do', '예산낭비신고하기(군민참여 신고그룹)')
|
|
# 재난·안전·민방위 강우정보
|
|
lnb('https://www.seocheon.go.kr/prog/rainStat/safe/sub07_05_01_01/list.do?siteCode=kor', '강우정보(재난안전)')
|
|
lnb('https://www.seocheon.go.kr/prog/airPollution/kor/sub07_04_14/list.do', '대기오염도(환경, 비교용)')
|