首页 > 代码库 > C# 判断网站是不是discuz论坛
C# 判断网站是不是discuz论坛
if (this.txturl.Text == "") { this.lblmess.Text = "请输入网址"; } else { GetHttp getHttp = new GetHttp(); string url = "http://" + this.txturl.Text + "/uc_server/control/admin/db.php"; try { string httpWebRequest = getHttp.GetHttpWebRequest(url); if (httpWebRequest.Contains("Access")) { this.lblmess.Text = "Discuz论坛程序!"; } else { this.lblmess.Text = "非论坛"; } } catch (WebException) { MessageBox.Show("域名输入错误!"); }
public string GetHttpWebRequest(string url) { Uri requestUri = new Uri(url); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(requestUri); httpWebRequest.UserAgent = "User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705"; httpWebRequest.Accept = "*/*"; httpWebRequest.KeepAlive = true; httpWebRequest.Headers.Add("Accept-Language", "zh-cn,en-us;q=0.5"); HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); Stream responseStream = httpWebResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("utf-8")); string result = streamReader.ReadToEnd(); streamReader.Close(); responseStream.Close(); httpWebResponse.Close(); return result; }
C# 判断网站是不是discuz论坛
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。