import requests,re,io
from bs4 import BeautifulSoup
import urllib3; urllib3.disable_warnings()
H={'User-Agent':'Mozilla/5.0'}
# 공지사항 board r50, known to have posts
for u in ["https://www.kdhc.co.kr/kdhc/bbs/B0000020/list.do?menuNo=200124",
          "https://www.kdhc.co.kr/kdhc/bbs/B0000117/list.do?menuNo=200560"]:
    r=requests.get(u,headers=H,timeout=25,verify=False)
    s=BeautifulSoup(r.content,'html.parser')
    print('URL',u)
    # find elements containing '건' or 'total' or page count
    for el in s.find_all(string=re.compile(r'건|페이지|Total|총')):
        t=el.strip()
        if t and len(t)<80: print('   txt:',repr(t))
    # count list rows
    for sel in ['table tbody tr','ul.board_list li','.board-list li','tbody tr']:
        rows=s.select(sel)
        if rows: print('   rows[%s]=%d'%(sel,len(rows)))
    # page links / last page
    pag=s.select('a[href*="pageIndex"], .paging a, .pagination a')
    print('   paglinks=',len(pag))
    print('---')
