Fastest C# Code to Download a Web Page

后端 未结 6 1047
不思量自难忘°
不思量自难忘° 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条回答
  •  梦毁少年i
    2021-01-30 07:03

    WebClient.DownloadString

    public static void DownloadString (string address)
    {
        WebClient client = new WebClient ();
        string reply = client.DownloadString (address);
    
        Console.WriteLine (reply);
    }
    

提交回复
热议问题