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