wudi

博客园 首页 新随笔 联系 订阅 管理

 private string GetSomeThingFromHtml(string url)
        {
            try
            {
               
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (Stream newStream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(newStream))
                    {
                        Regex regHtml = new Regex(@"正则想取的内容RegexOptions.IgnoreCase | RegexOptions.Compiled);
                        string html = reader.ReadToEnd();
                        MatchCollection col = regHtml.Matches(html);

                        return col.Count > 0 ? col[0].ToString().Split('=')[1] : String.Empty;
                    }
                }
            }
            catch (Exception)
            {
                return String.Empty;
            }
        }

posted on 2009-11-18 14:52  菜鸟吴迪  阅读(142)  评论(0编辑  收藏  举报