爬虫开发请求数据解决https证书问题

347次阅读
没有评论
爬虫开发请求数据解决https证书问题

1.在http辅助类中添加方法如下:

        private static bool RemoteCertificateValidate(object sender, X509Certificate cert,X509Chain chain, SslPolicyErrors error)
        {
            // trust any certificate!!!
            System.Console.WriteLine("Warning, trust any certificate");
            //为了通过证书验证,总是返回true
            return true;
        }

2.在http辅助类的构造方法添加如下代码:

ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;//验证服务器证书回调自动验证

参考:http://wangzhiyu811.blog.163.com/blog/static/127254044201222462536173/

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python教程2022-10-28发表,共计471字。
新手QQ群:570568346,欢迎进群讨论 Python51学习