Fastest C# Code to Download a Web Page

后端 未结 6 1044
不思量自难忘°
不思量自难忘° 2021-01-30 06:31

Given a URL, what would be the most efficient code to download the contents of that web page? I am only considering the HTML, not associated images, JS and CSS.

6条回答
  •  深忆病人
    2021-01-30 07:01

    Use the WebClient class from System.Net; on .NET 2.0 and higher.

    WebClient Client = new WebClient ();
    Client.DownloadFile("http://mysite.com/myfile.txt", " C:\myfile.txt");
    

提交回复
热议问题