DB_JOB/작업파일/공공기관3/완료/4.한국인터넷진흥원/_chkM.py
2026-06-26 09:47:44 +09:00

18 lines
961 B
Python

# coding: utf-8
import requests, re, io
H={'User-Agent':'Mozilla/5.0','Referer':'https://www.kisa.or.kr/'}
out=io.open('_chkM_out.txt','w',encoding='utf-8')
def totalnum(seq):
try:
h=requests.get('https://www.kisa.or.kr/%s'%seq,headers=H,timeout=20).content.decode('utf-8','replace')
m=re.search(r'var\s+totalNum\s*=\s*(\d+)',h)
kogl=bool(re.search(r'open(?:type|code)0*\d',h)) or ('kogl' in h.lower())
return (m.group(1) if m else 'noTotal'), kogl
except Exception as e:
return ('ERR:%s'%e), False
# 동향분석 8 tabs
for seq,name in [(20207,'전체동향'),(20205,'사이버위협'),(20206,'랜섬웨어'),(20201,'법제'),
(20202,'개인정보보호인터넷'),(20203,'글로벌정보보호'),(20204,'위치정보'),(20208,'글로벌디지털산업')]:
t,k=totalnum(seq); out.write('%s %s M=%s kogl=%s\n'%(seq,name,t,k))
out.close(); print(open('_chkM_out.txt',encoding='utf-8').read())