当前位置:编程学习 > C#/ASP.NET >>

怎样使用C#获取网页中的keywords和description

怎样使用C#获取网页中的title,keywords和description,WinForm和WebForm均可! --------------------编程问答-------------------- 通过正则获取title等
string str = "";
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(str);
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.GetEncoding("gb2312"));
            string content = sr.ReadToEnd();
            Console.WriteLine("{0}", Regex.Match(content, @"<title>([^<>]*)</title>").Groups[1].Value); --------------------编程问答-------------------- WebRequest oRequest = WebRequest.Create("http://www.taobaonzpd.com/");  
            WebResponse oResponse = oRequest.GetResponse();  
            StreamReader oReader = new StreamReader(oResponse.GetResponseStream(),Encoding.GetEncoding("GB2312"));  
            string html = oReader.ReadToEnd();  
            Match m = Regex.Match(html, "<title>(.*)</title>");  
            if (m.Groups.Count == 2)  
                Console.WriteLine(m.Groups[1].Value);  
            Console.ReadLine();   --------------------编程问答-------------------- 具体看:http://blog.csdn.net/hnliwh/article/details/7084150 --------------------编程问答--------------------
引用 1 楼 wuyq11 的回复:
通过正则获取title等
string str = "";
  HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(str);
  HttpWebResponse res = (HttpWebResponse)req.GetResponse();
  StreamReader sr = new StreamReader(re……
++http://popbayun.blog.sohu.com/41711632.html楼主再看看我给楼主找的。come on 楼主
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,