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

23 lines
1.1 KiB
Python

import requests, sys, re
from bs4 import BeautifulSoup
import urllib3
urllib3.disable_warnings()
sys.stdout.reconfigure(encoding='utf-8')
H = {'User-Agent':'Mozilla/5.0'}
def get(u):
r = requests.get(u, headers=H, timeout=20, verify=False)
r.encoding = r.apparent_encoding or 'utf-8'
return r.text
# 정보공개 메뉴 페이지
soup = BeautifulSoup(get('https://www.seocheon.go.kr/kor/sub01_02_10.do'), 'html.parser')
print('=== all a.link_3th on page ===')
for a in soup.select('a.link_3th'):
print(' ', repr(' '.join(a.get_text().split())[:30]), 'target=',a.get('target'),'href=',a.get('href'))
print('=== lnb / snb menu links with target=_blank ===')
for a in soup.select('.lnb a[target="_blank"], #snb a[target="_blank"], .snb a[target="_blank"], nav a[target="_blank"]'):
cls=a.get('class')
print(' ', repr(' '.join(a.get_text().split())[:30]), 'cls=',cls,'href=',a.get('href'))
print('=== sample lnb structure (first 40 a) ===')
for a in soup.select('.lnb a, #lnb a, #snb a, .snb a')[:40]:
print(' ', a.get('class'), a.get('target'), repr(' '.join(a.get_text().split())[:24]), (a.get('href') or '')[:40])