using (WebClient wc = new WebClient())
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var data = wc.DownloadData(url);
string html = Encoding.GetEncoding("UTF-8").GetString(data);
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
var data = wc.DownloadData(url);
string html = Encoding.GetEncoding("UTF-8").GetString(data);
}
因为ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 只有升级到.NET 4.5才可以用,所以在.NET4. 0只要在抓取前面加 ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072 就可以啦