网页抓取类

//--需要引用 using System.Net 以及 using System.IO;
private string GetContentFromUrll(string _requestUrl)
        {
            string _StrResponse ="";
            HttpWebRequest _WebRequest = ( HttpWebRequest )WebRequest.Create( _requestUrl );
            _WebRequest.Method = "GET";
            WebResponse _WebResponse = _WebRequest.GetResponse();
            StreamReader _ResponseStream = new StreamReader( _WebResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
            _StrResponse = _ResponseStream.ReadToEnd();
            _WebResponse.Close();
            _ResponseStream.Close();
            return _StrResponse;       
        }

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/21aspnet/archive/2007/03/23/1539255.aspx

原文地址:https://www.cnblogs.com/liufei88866/p/1534202.html