Python/Python for Windows
[Python] Counters를 이용한 IIS 웹 로그 IP주소 빈도 수 추출
Pydole
2018. 4. 13. 22:55
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