一行代码了解网站被访问最多的URL

转自:http://sesame.iteye.com/blog/1678326

有需求想分析下网站的被访问的TOP 10 URL是哪些,想到了apache 的cookie日志中有记录,在日志目录的cookie_log.*文件中,打开一个确实存在:

Log代码   收藏代码
  1. 112.113.241.58 - - - [09/Sep/2012:00:01:08 +0800"GET /dd.abc.com/favicon.ico HTTP/1.1" 200 1406 154 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1) QQBrowser/6.0"  
 

不过对每一个列对应的含义不是很清楚,看了下httpd.conf,

 

Html代码   收藏代码
  1. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined  
  2. LogFormat "%h %l %u %t \"%r\" %>s %b" common  

 

查了下apache的配置文档,了解了对应的含义。

 

写了一行shell脚本:

 

Shell代码   收藏代码
  1. cat cookie_log.0 | awk '{ print $8 }' | sed s/?.*//g |sort | uniq -c | sort -n -r |head -n 10  

 (uniq这个命令默认只删除紧挨的重复行,所以需要先sort下,再uniq)

 

得到以下结果,(具体网址用手动替换成*了)

 

 

结果代码   收藏代码
  1. 2713 /172.22.14.109/ok.htm  
  2. 2387 /*/order/orderList.htm  
  3. 1009 /*/favicon.ico  
  4.  990 /*/index.htm  
  5.  854 /*/wide/jhs/wlTrace.htm  
  6.  851 /*/aita/css/aita-main.css  
  7.  780 /*/order/orderDetail.htm  
  8.  715 /*/storage/stockInList.json  
  9.  519 /*/determine/deduce.json  
  10.  496 /*/order/channelOrderListLimit.json  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值