Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
4
import re
fr = open ("access.log", "r")
fw = open ("output.txt","w")
pipv4 = re.compile ("^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9][0-9]|[0-9])((\.25[0-5]|\.2[0-4][0-9]|\.1[0-9][0-9]|\.[0-9][0-9]|\.[0-9]){3}) ")
c = 0
l = fr.readlines()
for i in l:
if pipv4.search(i)!=None:
c += 1
fw.write(str(c))
fr.close()
fw.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment