我希望从c#获取任何chrome,firefox,ie等窗口的网页源代码 我该怎么用?
我的应用:
答案 0 :(得分:0)
您应该使用以下代码:
using System.Net;
//...
using (WebClient webClient = new WebClient ())
{
client.DownloadFile("http://yoursite.com/page.html", @"C:\localfile.html");
// Or you can get the file content without saving it:
string htmlCode = client.DownloadString("http://yoursite.com/page.html");
//...
}
在html代码中,您将获得预期的html源代码并将其显示在文本查看器中。