July 2017
Beginner to intermediate
420 pages
10h 56m
English
Alright, so this gets a little bit tricky. There's no real good way of identifying spiders or robots just based on the user string alone. But we can at least take a legitimate crack at it, and filter out anything that has the word "bot" in it, or anything from my caching plugin that might be requesting pages in advance as well. We'll also strip out our friend single dash. So, we will once again refine our script to, in addition to everything else, strip out any UserAgents that look fishy:
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() agent = access['user_agent'] if (not('bot' in agent or 'spider' ...Read now
Unlock full access