使用什么类和方法可以读取网页文件
比如地址如下:http://www.zgjrjw.com/index.shtml
如何使用程序读取这个文件

解决方案 »

  1.   

    WebClient
    WebRequest
    WebResponse
      

  2.   

    你如果是  C#  开发 w inform 话 WebBrowser 这个控件是很好用的!!
    里面的很多属性 可以方便的让你 得到网页上的信息
    网页地址 WebBrowser.Url = new uri("http://www.zgjrjw.com/index.shtml");网页内容 this.webBrowser.DocumentText
    或者里面的连接  COOKIE  都可以得到很实用
      

  3.   

    WebRequest wReq = WebRequest.Create(site);      // Set the HTTP-specific UserAgent property
          if (wReq is HttpWebRequest) 
          {
            ((HttpWebRequest)wReq).UserAgent = 
              ".NET Framework Example Client";
          }      // Get the response instance
          WebResponse wResp = wReq.GetResponse();      // Read an HTTP-specific property.
          if (wResp is HttpWebResponse)
          {
            DateTime updated = ((HttpWebResponse)wResp).LastModified;
          }      // Get the response stream.
          Stream respStream = wResp.GetResponseStream();     // This example uses a StreamReader to read the entire response
         // into a string and then writes the string to the console.
         StreamReader reader = 
           new StreamReader(respStream, Encoding.ASCII);
         String respHTML = reader.ReadToEnd();
         Console.WriteLine(respHTML);     // Close the response and response stream.
         wResp.Close();
      

  4.   

    string url = "http://www.zgjrjw.com/index.shtml";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    WebResponse response = request.GetResponse();
    Stream stream = response.GetResponseStream();
    StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default);
      

  5.   

    WebRequest sendReq = WebRequest.Create("http://www.zgjrjw.com/index.shtml");
    WebResponse recevieRes = sendReq.GetResponse();Stream receviceStream = recevieRes.GetResponseStream();
    Encoding encode = Encoding.GetEncoding("utf-8");
    StreamReader reader = new StreamReader(receviceStream, encode);