CookieContainer cc = new CookieContainer();
Encoding encoding = System.Text.Encoding.Default; string postData = "tpl_ok=&next_target=&tpl=mn&skip_ok=&aid=&need_pay=&need_coin=&pay_method=&u=http%3A%2F%2Fwww.baidu.com%2F&return_method=get&more_param=&return_type=&psp_tt=0&password=wujingxing&safeflg=0&isphone=tpl&username=wjxdbd&verifycode=&mem_pass=on";
byte[] byteArray = Encoding.encoding.GetBytes(postData); // 转化
HttpWebRequest webRequest2 = (HttpWebRequest)WebRequest.Create(new Uri("https://passport.baidu.com/?login"));
webRequest2.CookieContainer = cc;
webRequest2.Method = "POST";
webRequest2.Accept="image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
webRequest2.ContentLength=byteArray.Length;
webRequest2.ContentType = "application/x-www-form-urlencoded";
webRequest2.Referer="https://passport.baidu.com/?login&tpl=mn";
webRequest2.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)";
Stream newStream = webRequest2.GetRequestStream();
// Send the data.
newStream.Write(byteArray, 0, byteArray.Length); //写入参数
newStream.Close();
//HttpWebResponse response2 = (HttpWebResponse)webRequest2.GetResponse();
//StreamReader sr2=new StreamReader(response2.GetResponseStream(), Encoding.Default);
//string text2 = sr2.ReadToEnd();
webBrowser1.Navigate("https://www.baidu.com/");我这个是登录百度空间的。怎么总是登录不上呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货