
2011年我曾经对手头负责的WAP站的User_Agent分析过,通过当时的分析结果写过一些相应的处理规则。但近两年手机、手机浏览器的发展日新月异,原来的规则就慢慢的出现了不能很好兼容的情况,于是今天(2013.01.04)我又对现在WAP站的访问情况进行了分析。tcls188
借助Sqlserver等关系型可以对这些数据很好的进行分析、统计。tcls188以下是插入用户访问到的方法(我用的是Asp.net):
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 总共条数
--------------------------------------------
SELECT COUNT(*) AS Expr1
FROM headerinfo
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-29427-1.html
#给烊烊520#1128生日评论