Python Apache日志处理脚本

#!/usr/bin/python
#coding=gb2312 

f=open('/var/log/apache2/access.log','r');
log=f.readline().rstrip();
log_home=log.split();
print log_home;
ip=log_home[0];
date=log_home[3].replace('[','');
point=log_home[5].replace('"','');
path=log_home[6];
offer=log_home[8];
web=log_home[11].replace('"','');
print ip+'\t'+date+'\t'+point+'\t'+path+'\t'+offer+'\t'+web;
f.close();

 

posted @ 2013-03-04 15:47  墨迹哥's  阅读(444)  评论(0编辑  收藏  举报