我正在尝试从以下网站上抓取新闻:https://www.livescore.com/soccer/news/
using (Windows.Web.Http.HttpClient client = new Windows.Web.Http.HttpClient())
{
client.DefaultRequestHeaders.Add("User-Agent",
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident / 6.0)");
using (Windows.Web.Http.HttpResponseMessage response = await client.GetAsync(new Uri(pageURL)))
using (Windows.Web.Http.IHttpContent content = response.Content)
{
try
{
string result = await content.ReadAsStringAsync();
Debug.WriteLine(result);
}
}
}
我看到我收到一个包含response
的{{1}}
由于我在Your browser is out of date or some of its features are disabled
上,因此我移至Windows.Web
添加certificates
,并尝试添加以下UWP
certificates
但是我仍然从服务器上获得相同的HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.IncompleteChain);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.WrongUsage);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.RevocationInformationMissing);
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.RevocationFailure);
。
知道如何绕过这个吗?
编辑:他们确实有不安全的旧服务器http://www.livescore.com/,我想我可以在这里丢弃一切,但新闻不存在。
答案 0 :(得分:0)
我认为问题是用户代理字符串。您告诉站点您使用的浏览器是Internet Explorer 10。 查看此页面http://www.useragentstring.com/pages/useragentstring.php?name=Internet+Explorer并尝试使用Internet Explorer 11用户代理(在通过ie11浏览器打开该页面以检查其功能之前)