xxx.xxx.xxx.xxx IP 패턴을 가장 많은 10개 추출 IIS로그 1.3G를 샘플로 실행해 보았다.
정규식을 이용하여 원하는 데이터를 출력
import collections
import re
from datetime import datetime
def timecheck():
return datetime.today().strftime('%X')
print(timecheck())
words = re.findall(r'\d{,3}[.]+\d{,3}[.]+\d{,3}[.]+\d{,3}[.]',open(파일, errors='replace').read().lower())
print(collections.Counter(words).most_common(10))
print(timecheck())
--------------------------------------------------------------------------------------------------------------
22:45:54
.........................
22:47:47
'Python > Python for Windows' 카테고리의 다른 글
[Python] Check shared folder of Windows operating system using subprocess and regular expression (0) | 2018.05.04 |
---|---|
[Python] SQLite 메모리DB를 활용한 파이썬 IIS 로그파서 (0) | 2018.04.27 |
[Python] xcopy DOS명령어를 조합한 증분 백업 (0) | 2018.04.20 |
[Python] 윈도우 서버에서 SMTP서버로 메일 발송 (2) (0) | 2018.04.18 |
[Python] 자신의 로컬 IP 알아내기 (0) | 2018.04.18 |
zipfile을 이용한 특정폴더에 있는 모든 파일 압축 (0) | 2018.04.18 |
[Python] 윈도우 netstat 명령어를 활용하여 아웃바운드 IP와 포트 추출 (0) | 2018.04.15 |
[Python] 하위 디렉토리 파일크기와 라인 수 추출 (0) | 2018.04.12 |