您的位置:首页 > 编程语言 > C#

C#简单爬虫核心代码

2014-04-11 14:19 162 查看
string strr = 网页url;

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

System.Net.WebClient client = new System.Net.WebClient();

string reply = string.Empty;

reply = client.DownloadString(strr);

private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)

{

// trust any certificate!!!

//为了通过证书验证,总是返回true

return true;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  爬虫 c#