怎么获取网站的描述
比如输入一个网址,一点按钮能得到对应网址的描述,高手帮帮忙 --------------------编程问答-------------------- 网址的描述指的是?title? --------------------编程问答-------------------- <meta content="怎么获取网站 描述 .NET技术 ASP.NET" name="Keywords"/><meta content="比如输入一个网址 一点按钮能 到对应网址 描述 高手帮帮忙" name="description"/>
<title>怎么获取网站的描述 - .NET技术 / ASP.NET</title>
是指的这些吗? --------------------编程问答-------------------- WebRequest方式:
private void WebRequestMethod()
{
WebRequest request = (HttpWebRequest)WebRequest.Create("http://www.baidu.com");
WebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
string strContent = reader.ReadToEnd();
tboxTitle.Text = strContent.Substring(strContent.IndexOf("<title>")+7, strContent.IndexOf("</title>") - strContent.IndexOf("<title>")-7);
}
WebClient方式:
private void WebClientMethod()
{
WebClient client = new WebClient();
string strContent = client.DownloadString("http://www.baidu.com");
tboxTitle.Text = strContent.Substring(strContent.IndexOf("<title>") + 7, strContent.IndexOf("</title>") - strContent.IndexOf("<title>") - 7);
}
上面截取字符串方式可能有时候会错,最好用正则表达式匹配title,keywords以及description,但自己正则表达式没有研究!但思路是这样的. --------------------编程问答-------------------- 应该用3楼的方法试试。 --------------------编程问答-------------------- 主要还是不太明白楼主说的网站的描述具体指的是什么意思 --------------------编程问答-------------------- 我说的描述是这个<meta content="比如输入一个网址 一点按钮能 到对应网址 描述 高手帮帮忙" name="description"/> 3楼的方法我明白,不过有些网站不存在 meta标签. 有可能是某些功能直接后加到页面上去的 这样的话好像用3楼的方法 就截取不到了 额...
--------------------编程问答-------------------- 这个有意思。可能以后能用得到。 --------------------编程问答-------------------- 不给分啊,没意思 --------------------编程问答-------------------- Refer:
http://www.cnblogs.com/insus/articles/2023352.html
补充:.NET技术 , ASP.NET