공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
17 lines
685 B
Python
17 lines
685 B
Python
# -*- coding: utf-8 -*-
|
|
import sys,io,urllib.request,ssl,re
|
|
from bs4 import BeautifulSoup
|
|
sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
|
|
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
|
|
def get(u):
|
|
req=urllib.request.Request(u,headers={'User-Agent':'Mozilla/5.0'})
|
|
return urllib.request.urlopen(req,timeout=25,context=ctx).read().decode('utf-8','ignore')
|
|
h=get('https://www.chungju.go.kr/www/sitemap.do?key=553')
|
|
s=BeautifulSoup(h,'html.parser')
|
|
boxes=s.select('div.sitemap_box')
|
|
print('sitemap_box',len(boxes))
|
|
if boxes:
|
|
b=boxes[0]
|
|
print('첫박스 구조 일부:')
|
|
print(re.sub(r'\s+',' ',str(b))[:1400])
|