Find all of the hosts that access robots.txt in a single log file
(filename)
| 5 | import glob |
| 6 | |
| 7 | def 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 | |
| 19 | def find_all_robots(logdir): |
| 20 | ''' |