【发布时间】:2014-01-30 09:49:18
【问题描述】:
我想用c#从任何chrome、firefox、ie等窗口获取网页源代码 我应该用什么?
我的应用:
【问题讨论】:
我想用c#从任何chrome、firefox、ie等窗口获取网页源代码 我应该用什么?
我的应用:
【问题讨论】:
你应该使用这个代码:
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");
//...
}
在 htmlCode 中,您将按预期获得 html 源代码并将其显示在文本查看器上。
【讨论】: