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))
