C# post 登录百度空间的问题。。。求帮忙 谢谢大家了

wjxdgz 2012-03-21 08:37:01
 CookieContainer cc = new CookieContainer();
string postData = "tpl_ok=&next_t";
byte[] byteArray = Encoding.UTF8.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/");//这里不知道是不是对的,是想查看下登录成功了没有。
每次都登录不上去了。。。是我那里写错了么?谢谢大家的帮忙了。
...全文
97 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
clairelss 2012-04-20
  • 打赏
  • 举报
回复
樓主 postData 寫的太簡單了吧 幫頂 等高手!!!

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧