采集网页代码

             string weatherhtml = string.Empty;
                
            HttpWebRequest webrt = (HttpWebRequest)WebRequest.Create("http://www.fjqx.gov.cn");

            HttpWebResponse webrs = (HttpWebResponse)webrt.GetResponse();
            //读取数据
            Stream stream = webrs.GetResponseStream();
            StreamReader srm = new StreamReader(stream, System.Text.Encoding.Default);
            weatherhtml = srm.ReadToEnd();
            //关闭打开的资源
            srm.Close();
            stream.Close();
            webrs.Close();

posted on 2011-12-01 08:52  张扬个性,敢为天下先  阅读(551)  评论(0编辑  收藏  举报