关于登陆百度的问题 新手求教
登陆百度的代码 没有错误提示 但是登陆失败Private Function CheckValidationResult(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyerrors As SslPolicyErrors) As Boolean
Return True
End Function
main sub
Dim uristr As String = "https://passport.baidu.com?login"
Dim Cookies As New CookieContainer
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
Dim ServerCertificateValidationCallback As New RemoteCertificateValidationCallback(AddressOf CheckValidationResult)
Dim poststr As String = "tpl_ok=&next_target=&tpl=mn&skip_ok=&aid=&need_pay=&need_coin=&pay_method=&u=http://www.baidu.com/index.php&return_method=get&more_param=tn=leizhen&ch=12&return_type=&psp_tt=0&password=*******&safeflg=0&username=********&verifycode="
Dim data() As Byte = Encoding.GetEncoding("GB2312").GetBytes(poststr)
Dim request As HttpWebRequest = CType(HttpWebRequest.Create(New Uri(uristr)), HttpWebRequest)
request.ServicePoint.Expect100Continue = False
request.Accept = "*/*"
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
request.Referer = "https://passport.baidu.com?login"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = data.Length
request.KeepAlive = True
request.CookieContainer = Cookies
request.AllowAutoRedirect = True
request.Timeout = 300000
request.Method = "POST"
Dim writer As Stream = request.GetRequestStream()
writer.Write(data, 0, data.Length)
writer.Flush()
writer.Close()
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Dim res As Stream = response.GetResponseStream()
Dim reader As New StreamReader(res, Encoding.GetEncoding("GB2312"))
Dim html As String = reader.ReadToEnd()
reader.Close()
res.Close()
response.Close()
Console.WriteLine(html)
Console.ReadKey()
end sub