MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / find_robots

Function find_robots

src/12/simple_parallel_programming/findrobots.py:7–17  ·  view source on GitHub ↗

Find all of the hosts that access robots.txt in a single log file

(filename)

Source from the content-addressed store, hash-verified

5import glob
6
7def find_robots(filename):
8 '''
9 Find all of the hosts that access robots.txt in a single log file
10 '''
11 robots = set()
12 with gzip.open(filename) as f:
13 for line in io.TextIOWrapper(f,encoding='ascii'):
14 fields = line.split()
15 if fields[6] == '/robots.txt':
16 robots.add(fields[0])
17 return robots
18
19def find_all_robots(logdir):
20 '''

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected