Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

PYTHON

import re


def logs():
    logs = []
    w = '(?P<host>(?:d+.){3}d+)s+(?:S+)s+(?P<user_name>S+)s+[(?P<time>[-+ws:/]+)]s+"(?P<request>.+?.+?)"'
    with open("assets/logdata.txt", "r") as f:
        logdata = f.read()
    for m in re.finditer(w, logdata):
        logs.append(m.groupdict())
    return logs
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #PYTHON
ADD COMMENT
Topic
Name
9+6 =