C# 判断网站是不是discuz论坛
Posted 代码描绘人生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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论坛的主要内容,如果未能解决你的问题,请参考以下文章