想写一个python分析统计apache 日志文件的脚本
PHP中文网
PHP中文网 2017-04-18 10:34:55
0
1
594

想写一个python分析统计apache 网站日志文件并将统计后的数据存入mysql中的的脚本,有没有参考的,没有思路
主要是统计 哪些url被爬取了 及 被爬取次数,以及IP这两个

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
Ty80

First normalize the original data, then set the key value yourself, then use the Counter of collections to count, and then traverse and write it to the db. The approximate code is as follows:

data = ['/a 1.2.1.2', '/b 2.2.2.2', '/c 1.1.1.1', '/d 2.2.2.2', '/d 2.2.2.2']
from collections import Counter
c = Counter(data)
print c
Counter({'/d 2.2.2.2': 2, '/b 2.2.2.2': 1, '/a 1.2.1.2': 1, '/c 1.1.1.1': 1})

You can also maintain the dictionary yourself, the key is: /PATH:IP or something, you can set it yourself, and then just add it while traversing it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!