공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
804 B
Python
18 lines
804 B
Python
# -*- coding: utf-8 -*-
|
|
import sys, urllib.request, ssl, re
|
|
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.gimje.go.kr/index.gimje?menuCd=DOM_000000101004002001'
|
|
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')
|
|
# find any div whose class contains basic_tab
|
|
for div in soup.find_all('div'):
|
|
cls=' '.join(div.get('class') or [])
|
|
if 'basic_tab' in cls:
|
|
print('=== DIV class=', cls, '===')
|
|
for a in div.find_all('a'):
|
|
print(' a href=', a.get('href'), '| text=', a.get_text(strip=True))
|