例如我桌面上打开了一个IE,IE中打开百度。
怎么用C#实现自动将百度这个网页另存为HTML存到我的机器硬盘上?C#

解决方案 »

  1.   

    跟c#没有半点关系。c#编译的代码只能在web服务器端执行。你应该去 javascript 论坛问这个问题。
      

  2.   


    我想他说的不一定是asp.net, 可能是console app或其他吧。楼主可以把你的background说一下。
      

  3.   


    WebClient mywebClient = new WebClient();
    byte[] mydatabuffer = mywebClient.DownloadData(url);
    string html = Encoding.UTF8.GetString(mydatabuffer);
     System.IO.File.WriteAllText(路径, html);
      

  4.   

      保存html可以用httpwebrequest或者 webclient 或者webbrowser 都可以
      

  5.   

    WebRequest req = WebRequest.Create(uri);
        WebResponse res = req.GetResponse();    // GetResponse blocks until the response arrives
        Stream ReceiveStream = res.GetResponseStream();    // Read the stream into a string
        StreamReader sr = new StreamReader( ReceiveStream );
        string resultstring = sr.ReadToEnd();