공공기관2 작업 중. _temp 몽타주(재생성가능)는 제외. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
2.5 KiB
Python
56 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
||
import requests, urllib3, re, sys, io
|
||
from bs4 import BeautifulSoup
|
||
import openpyxl
|
||
urllib3.disable_warnings()
|
||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||
H={'User-Agent':'Mozilla/5.0'}
|
||
BASE='https://www.jejusi.go.kr'
|
||
def get(u): return requests.get(u, timeout=25, headers=H, verify=False, allow_redirects=True)
|
||
|
||
# old N/O reference rows
|
||
wb=openpyxl.load_workbook('제주특별자치도_제주시.xlsx'); ws=wb.active
|
||
def row(r): return {'D':ws.cell(r,4).value,'E':ws.cell(r,5).value,'F':ws.cell(r,6).value,'K':ws.cell(r,11).value,'L':ws.cell(r,12).value,'M':ws.cell(r,13).value,'N':ws.cell(r,14).value,'O':ws.cell(r,15).value,'P':ws.cell(r,16).value,'Q':ws.cell(r,17).value}
|
||
print('--- old carry rows ---')
|
||
for r in [4,5,7,8,10,11,12,13,93,224]:
|
||
d=row(r); print(r, d['F'] or d['E'], '| N=',d['N'],'O=',d['O'],'P=',d['P'],'Q=',d['Q'],'M=',d['M'])
|
||
|
||
def total(u):
|
||
rr=get(u); s=BeautifulSoup(rr.content,'html.parser'); txt=s.get_text(' ',strip=True)
|
||
m=re.search(r'(?:전체|총)\s*[::]?\s*([\d,]+)\s*건', txt)
|
||
return int(m.group(1).replace(',','')) if m else None
|
||
|
||
def kogl(u):
|
||
rr=get(u); s=BeautifulSoup(rr.content,'html.parser'); txt=s.get_text(' ',strip=True)
|
||
types=sorted(set(re.findall(r'공공누리[ \xa0]*제([1-4])유형', txt)))
|
||
return types
|
||
|
||
def imgs(u):
|
||
# sample image content check on listing/detail
|
||
rr=get(u); s=BeautifulSoup(rr.content,'html.parser')
|
||
big=0
|
||
for im in s.find_all('img'):
|
||
src=(im.get('src') or '')
|
||
if any(x in src for x in ['icon','btn','blank','no_img','logo','move','sns','common','/img/']): continue
|
||
big+=1
|
||
return big
|
||
|
||
print('\n--- new leaves M / KOGL ---')
|
||
new=[('카드뉴스','/news/communite/cardNews.do'),
|
||
('사진이야기','/news/communite/photoStory.do'),
|
||
('열린제주시','/news/ebook/openEbookList.do'),
|
||
('열린제주시 구독신청','/news/ebook/applyEbook.do'),
|
||
('독자투고','/news/ebook/readerSubmission.do'),
|
||
('기타간행물','/news/ebook/jejusiEbookList.do'),
|
||
('보도자료','/news/communite/report.do'),
|
||
('해명자료','/news/communite/explane.do'),
|
||
('와우 제주시','/news/communite/advertise.do'),
|
||
('읍면동소식','/news/areaNews.do'),
|
||
('영상이야기','/news/jejustory/mstroy.do'),
|
||
('문화행사안내','/news/notice/culture.do')]
|
||
for nm,u in new:
|
||
try:
|
||
print(f'{nm:14s} M={total(BASE+u)} KOGL={kogl(BASE+u)} URL={u}')
|
||
except Exception as e:
|
||
print(nm,'ERR',str(e)[:50])
|