113.64.79.0 - - [04/Jul/2012:10:03:41 +0800] "GET /upfile/201207/201207040939177110.jpg HTTP/1.1" 200 18315 "http://www.liketry.com/paytry.php" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.2; 360SE)" -
27.115.127.146 - - [04/Jul/2012:10:03:41 +0800] "GET /images/default/fufei.png HTTP/1.1" 304 0 "http://www.liketry.com/index.php" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.59 http://bsalsa.com/ EmbeddedWB- 14.59 from: http://bsalsa.com/ ; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; Maxthon 2.0)" -
116.21.255.71 - - [04/Jul/2012:10:03:41 +0800] "GET /images/ui-bg_glass_100_f6f6f6_1x400.png HTTP/1.1" 200 1009 "http://www.liketry.com/user_login.php?returnurl=http%3A%2F%2Fwww.liketry.com%2Fget_password.php%3Fmail%3D512695867%40qq.com%26&rr=0&[email protected]&error=5a+G56CB6ZSZ6K+v" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; 360SE)" -
类似这种记录 一个 有 一万条
我取了三条
我需要 从这些数据中 的到 做例子 字符串中 "http: xxxx" 前面的 那个流量数据
求方法
27.115.127.146 - - [04/Jul/2012:10:03:41 +0800] "GET /images/default/fufei.png HTTP/1.1" 304 0 "http://www.liketry.com/index.php" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.59 http://bsalsa.com/ EmbeddedWB- 14.59 from: http://bsalsa.com/ ; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; Maxthon 2.0)" -
116.21.255.71 - - [04/Jul/2012:10:03:41 +0800] "GET /images/ui-bg_glass_100_f6f6f6_1x400.png HTTP/1.1" 200 1009 "http://www.liketry.com/user_login.php?returnurl=http%3A%2F%2Fwww.liketry.com%2Fget_password.php%3Fmail%3D512695867%40qq.com%26&rr=0&[email protected]&error=5a+G56CB6ZSZ6K+v" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; 360SE)" -
类似这种记录 一个 有 一万条
我取了三条
我需要 从这些数据中 的到 做例子 字符串中 "http: xxxx" 前面的 那个流量数据
求方法
27.115.127.146 - - [04/Jul/2012:10:03:41 +0800] "GET /images/default/fufei.png HTTP/1.1" 304 0 "http://www.liketry.com/index.php" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.59 http://bsalsa.com/ EmbeddedWB- 14.59 from: http://bsalsa.com/ ; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; Maxthon 2.0)" -
116.21.255.71 - - [04/Jul/2012:10:03:41 +0800] "GET /images/ui-bg_glass_100_f6f6f6_1x400.png HTTP/1.1" 200 1009 "http://www.liketry.com/user_login.php?returnurl=http%3A%2F%2Fwww.liketry.com%2Fget_password.php%3Fmail%3D512695867%40qq.com%26&rr=0&[email protected]&error=5a+G56CB6ZSZ6K+v" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; 360SE)" -';
preg_match_all('/HTTP\/1\.1\"[ ]+\w+[ ]+(\d+)[ ]+\"/', $s, $a);
p($a[1]);
/**
输出:
Array
(
[0] => 18315
[1] => 0
[2] => 1009
)
*/
如果再区分出 就是GET 后面有/UPFILE 的和不是的要分开统计呢 还有得到 流量前面的 数据 200 或者304
// 这个实现有多种方法,现在列出其中的一种preg_match_all('/\"GET[ ]*\/upfile[^ ]+[ ]+HTTP\/1\.1\"[ ]+\w+[ ]+(\d+)[ ]+\"/', $s, $a1);
preg_match_all('/\"GET[ ]*\/(?!upfile)[^ ]+[ ]+HTTP\/1\.1\"[ ]+(\d+)[ ]+(\d+)[ ]+\"/', $s, $a2);
//p($a1);
p($a2);
preg_match_all('/\"GET[ ]*\/(?!upfile)[^ ]+[ ]+HTTP\/1\.1\"[ ]+(\d+)[ ]+(\d+)[ ]+\"/', $s, $a2);
//p($a1);
p($a2);