主页 > 编程资料 > C# >
发布时间:2015-09-26 作者:网络 阅读:178次
  public string GetWeb(string website)
  {
   try
   {
    string strHtmlContent="";
    string SourceUrl=website;
    System.Net.HttpWebRequest myrequest=(System.Net.HttpWebRequest)System.Net.WebRequest.Create(SourceUrl);
    myrequest.Timeout=5000;
    myrequest.Headers.Set("Pragma", "no-cache");
    System.Net.HttpWebResponse myresponse=(System.Net.HttpWebResponse)myrequest.GetResponse();
    System.IO.Stream mystream=myresponse.GetResponseStream();
    System.Text.Encoding myencoding=System.Text.Encoding.GetEncoding("Gb2312");
    System.IO.StreamReader mystreamreader=new System.IO.StreamReader(mystream,myencoding);
    strHtmlContent=mystreamreader.ReadToEnd();
    return strHtmlContent;   
   }
   catch
   {
    return "读取错误";
   }
  } 

<> <>
关键字词: