DB_JOB/_스크립트/_probe5.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

38 lines
1.2 KiB
Python

"""Inspect main pages of 아산시, 부여군, 서산시 — grep for 사이트맵 keyword anywhere."""
import re
import warnings
from urllib.parse import urljoin, urlparse
import requests
warnings.filterwarnings('ignore')
UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
H = {'User-Agent': UA}
PAGES = {
'아산시': 'https://www.asan.go.kr/main/',
'부여군': 'https://www.buyeo.go.kr/html/kr/',
'서산시': 'https://www.seosan.go.kr/www/index.do',
}
def fetch(url):
r = requests.get(url, headers=H, timeout=15, verify=False, allow_redirects=True)
r.encoding = r.apparent_encoding
return r.status_code, r.url, r.text
for name, url in PAGES.items():
print(f'\n=== {name} === {url}')
code, real, html = fetch(url)
print(f' HTTP {code}, len {len(html)}')
# Search for 사이트맵 or sitemap or allMenu
for keyword in ['사이트맵', 'sitemap', 'allMenu', '전체메뉴', 'totalMenu']:
pat = re.compile(r'[\'"][^\'"]*' + keyword + r'[^\'"]*[\'"]', re.I)
matches = pat.findall(html)[:10]
if matches:
print(f' "{keyword}" 매칭:')
for m in matches:
print(f' {m}')