当前位置:编程学习 > wap >>

对WAP站点的User_Agent最新分析

2011年我曾经对手头负责的WAP站的User_Agent分析过,通过当时的分析结果写过一些相应的处理规则。但近两年手机、手机浏览器的发展日新月异,原来的规则就慢慢的出现了不能很好兼容的情况,于是今天(2013.01.04)我又对现在WAP站的访问情况进行了分析。
 
借助Sqlserver等关系型数据库可以对这些数据很好的进行分析、统计。以下是插入用户访问到数据库的方法(我用的是Asp.net):
 
[csharp]  
SqlConnection conn = new SqlConnection("server=.;database=mobile;uid=test2011;pwd=test2011;");  
string sqlText = "insert into headerinfo(accept,user_agent,all_http,visit_ip) values(@accept,@user_agent,@all_http,@visit_ip)";  
SqlCommand command = new SqlCommand(sqlText, conn);  
command.CommandType = CommandType.Text;  
try  
{  
    conn.Open();  
    command.Parameters.Add("@accept", SqlDbType.VarChar, 8000);  
    command.Parameters.Add("@user_agent", SqlDbType.VarChar, 8000);  
    command.Parameters.Add("@all_http", SqlDbType.VarChar, 8000);  
    command.Parameters.Add("@visit_ip", SqlDbType.VarChar, 8000);  
    command.Parameters[0].Value = FormatInsertData(Request.Headers["Accept"]);  
    command.Parameters[1].Value = FormatInsertData(Request.UserAgent);  
    command.Parameters[2].Value = FormatInsertData(Request.ServerVariables["ALL_HTTP"]);  
    command.Parameters[3].Value = IPAddress;  
    command.ExecuteNonQuery();  
}  
catch (Exception ex)  
{  
}  
  
finally  
{  
    if (conn.State == ConnectionState.Open)  
    {  
        conn.Close();  
    }  
}  
 
我保存了几分钟内的数据,总共有14899条,下面是我借助SqlServer查询分析器得到的分析结果。
 
-----------------------------------------------
 
所有
select count(*) from headerinfo
 
14899 总共条数
--------------------------------------------
 
iOS android 空 其它
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE 'iuc%') OR
      (User_Agent LIKE 'juc%') OR
      (User_Agent LIKE '%android%') OR
      (User_Agent LIKE '%ios%') OR
      (User_Agent LIKE '%iphone%')
      
6589  android,iOS    
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE '')
 
 
1262  user_agent为空
  
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent NOT LIKE 'iuc%') AND (User_Agent NOT LIKE 'juc%') AND 
      (User_Agent NOT LIKE '%android%') AND (User_Agent NOT LIKE '%ios%') AND 
      (User_Agent NOT LIKE '%iphone%') AND (User_Agent NOT LIKE '')
 
 
7048 其他
-----------------------------------------------
iOS
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE '%ios%') OR
      (User_Agent LIKE '%iphone%') OR
      (User_Agent LIKE '%ipad%') OR
      (User_Agent LIKE '%ipod%') OR
      (User_Agent LIKE '%itouch%')
      
1147  苹果系列
--------------------------------------------
iOS ucweb极速
 
 
SELECT *
FROM headerinfo
WHERE (User_Agent LIKE 'iuc%')
 
 
725 ucweb 极速
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE '%iphone%')
 
 
422
 
 
SELECT *
FROM headerinfo
WHERE (User_Agent LIKE 'iuc%') AND (User_Agent LIKE '%iphone%')
 
 
0
--------------------------------------------  
Android
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE '%android%')
 
 
2894  含有android关键字
--------------------------------------------
Android ucweb极速
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE 'juc%')
 
 
2557   Android下 ucweb 极速
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE 'juc%') AND (User_Agent LIKE '%android%')
 
 
14  由此可见大部分都不含有android
--------------------------------------------
iOS android下 ucweb极速版
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent LIKE 'iuc%') OR
      (User_Agent LIKE 'juc%')
      
3282      
--------------------------------------------
 
其它
--------------------------------------------
其它--nokia
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent NOT LIKE 'iuc%') AND (User_Agent NOT LIKE 'juc%') AND 
      (User_Agent NOT LIKE '%android%') AND (User_Agent NOT LIKE '%ios%') AND 
      (User_Agent NOT LIKE '%iphone%') AND (User_Agent LIKE '%nokia%' or user_agent like '%SymbianOS%')
      
3095 nokia,sysbianOS
---------------------------------------------        
其它--mtk山寨机
  
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_Agent NOT LIKE 'iuc%') AND (User_Agent NOT LIKE 'juc%') AND 
      (User_Agent NOT LIKE '%android%') AND (User_Agent NOT LIKE '%ios%') AND 
      (User_Agent NOT LIKE '%iphone%') AND (User_Agent NOT LIKE '%nokia%') AND 
      (User_Agent LIKE '%maui%')
      
327  mtk山寨机
---------------------------------------------
其它--java最早的按键手机
 
 
SELECT COUNT(*) AS Expr1
FROM headerinfo
WHERE (User_A
补充:Web开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,