【发布时间】:2012-08-25 10:47:43
【问题描述】:
我正在尝试下载网页:
string remoteUri = "http://whois.domaintools.com/94.100.179.159";
WebClient myWebClient = new WebClient();
byte[] myDataBuffer = myWebClient.DownloadData(remoteUri);
string download = Encoding.ASCII.GetString(myDataBuffer);
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(download);
doc.Save("file1.htm");
有错误
webexception 未处理:(403) Forbidden。
还有其他方法可以下载页面吗? 我试过 HtmlDocument 类,但我可以看到它需要在浏览器中加载网页。
HtmlWeb hwObject = new HtmlWeb();
string ip = "http://whois.domaintools.com/";
HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load(ip);
foreach (HtmlNode link in htmldocObject.DocumentNode.SelectNodes("//meta[@name = 'description']"))
{
...
}
【问题讨论】:
标签: c# webclient html-agility-pack