问题描述
我正在尝试将网页 (https://saleslink.aa.com/en-US/#/home) 的 html 下载为字符串以使用 HtmlAgilityPack 进一步解析 但是它抛出了 400 个错误的 Request ,下面是我试过的代码。
using (WebClient client = new WebClient())
{
#region Html Download
string baseURL = "https://saleslink.aa.com/en-US/#/home";
client.Headers["Content-Type"] = "application/json;charset=UTF-8";
string html = client.DownloadString(baseURL);
#endregion
}
使用 HtmlAgilityPack 的代码方法 2(版本 1.11.34)
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("https://saleslink.aa.com/en-US/#/home");
也尝试设置下面的属性
using (WebClient client = new WebClient())
{
client.Headers.Add("Accept-Language","en-US");
client.Headers.Add("Content-Type","application/json;charset=UTF-8");
client.Headers.Add("Accept","text/html,application/xhtml+xml,*/*");
client.Headers.Add("User-Agent","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
html = client.DownloadString("https://saleslink.aa.com/en-US/#/home");
}
还是出现同样的错误,
此处是否缺少某些内容或需要对 URL 中的 # 符号进行转义?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)