我正在用C#编写一个应用程序,有没有一种方法只通过给我的程序URL来下载HTML页面。例如,我的程序将获取URL www.google.com 并下载HTML页面?
using System;
using System.Net;
using System.IO;
public static string Download (string uri)
{
WebClient client = new WebClient ();
Stream data = client.OpenRead (uri);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
data.Close ();
reader.Close ();
return s;
}