July 2017
Beginner to intermediate
420 pages
10h 56m
English
Now, I know that the data that I care about, you know in the spirit of the thing I'm trying to figure out is, people getting web pages from my website. So, a legitimate thing for me to do is to filter out anything that's not a get request, out of these logs. So, let's do that next. We're going to check again if we have three fields in our request field, and then we're also going to check if the action is get. If it's not, we're just going to ignore that line entirely:
URLCounts = {}with open(logPath, "r") as f: for line in (l.rstrip() for l in f): match= format_pat.match(line) if match: access = match.groupdict() request = access['request'] fields = request.split() if (len(fields) == 3): (action, ...Read now
Unlock full access