- 공공기관2/3 작업본 + 오늘 제출 17곳 D~J 카테고리 셀병합 정상화 - 한국지역난방공사 옵션2(고아셀 F98 수정)+전행 높이17 - 제출_프리랜서2_2026-06-21.zip 생성(17개 xlsx, 2,468행) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
23 lines
911 B
Python
23 lines
911 B
Python
import requests,re,io
|
|
from bs4 import BeautifulSoup
|
|
import urllib3; urllib3.disable_warnings()
|
|
H={'User-Agent':'Mozilla/5.0'}
|
|
u="https://www.kdhc.co.kr/kdhc/bbs/B0000020/list.do?menuNo=200124"
|
|
r=requests.get(u,headers=H,timeout=25,verify=False)
|
|
s=BeautifulSoup(r.content,'html.parser')
|
|
# locate '전체게시물'
|
|
import unicodedata
|
|
for el in s.find_all(string=re.compile('전체게시물')):
|
|
parent=el.parent
|
|
print('전체게시물 parent html:', parent)
|
|
print('parent text:', parent.get_text(' ',strip=True))
|
|
gp=parent.parent
|
|
print('grandparent text:', gp.get_text(' ',strip=True)[:120])
|
|
break
|
|
# page indicator full
|
|
for el in s.find_all(string=re.compile(r'\d+\s*/\s*\d+\s*페이지')):
|
|
print('pageind:',el.strip())
|
|
# pagination href pattern
|
|
for a in s.select('.paging a, .pagination a, a[href*="pageIndex"]')[:5]:
|
|
print('pag href:',a.get('href'),'txt:',a.get_text(strip=True))
|