DB_JOB/작업파일/공공기관2/10.한국지역난방공사/_boardM_all.py
hehihoho3 b0acd1e705 백업: 셀병합 정상화(D~J)+KDHC 옵션2/행높이17, 오늘(06-21) 제출 17곳 검수·압축
- 공공기관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>
2026-06-21 13:21:26 +09:00

30 lines
1.4 KiB
Python

import openpyxl,requests,re,io,json,time,sys
from bs4 import BeautifulSoup
import urllib3; urllib3.disable_warnings()
H={'User-Agent':'Mozilla/5.0'}
def fetch(u): return requests.get(u,headers=H,timeout=25,verify=False)
def maxno(url):
try: r=fetch(url); s=BeautifulSoup(r.content,'html.parser')
except Exception as e: return ('ERR',str(e)[:25])
rows=s.select('table tbody tr')
pi=s.find(string=re.compile(r'(\d+)\s*/\s*(\d+)\s*페이지'))
P=int(re.search(r'(\d+)\s*/\s*(\d+)',pi).group(2)) if pi else None
nums=[]
for tr in rows:
tds=tr.find_all(['td','th'])
if tds and tds[0].get_text(strip=True).isdigit(): nums.append(int(tds[0].get_text(strip=True)))
if nums: return (max(nums),f'maxno P{P}')
if rows: return (len([t for t in rows if t.find_all('td')]), f'rowcnt P{P}')
return (0,'norows')
wb=openpyxl.load_workbook('한국지역난방공사.xlsx'); ws=wb.active
rep=[]
for r in range(3,ws.max_row+1):
if ws.cell(r,12).value!='게시판': continue
k=ws.cell(r,11).value; curM=ws.cell(r,13).value
F=ws.cell(r,6).value; G=ws.cell(r,7).value
M,tag=maxno(k); time.sleep(0.08)
rep.append({'r':r,'curM':curM,'newM':M,'tag':tag,'label':G or F,'k':k})
io.open('_boardM_all.json','w',encoding='utf-8').write(json.dumps(rep,ensure_ascii=False,indent=0))
chg=[x for x in rep if str(x['curM'])!=str(x['newM']) and isinstance(x['newM'],int)]
print('total boards',len(rep),'would change',len(chg))