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

wjxdyx 2012-03-26 11:26:17


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/");


我这个是登录百度空间的。怎么总是登录不上呢?
...全文
350 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
色拉油 2012-03-31
  • 打赏
  • 举报
回复
上网上搜搜js跨域post
qq2503166366 2012-03-31
  • 打赏
  • 举报
回复
遇到相同的问题。。。等高手来指教
shen_laofu 2012-03-31
  • 打赏
  • 举报
回复
这里有现成的,直接使用:

http://blog.csdn.net/zhoufoxcn/article/details/6404236
wjxdyx 2012-03-30
  • 打赏
  • 举报
回复
没人 帮忙么。。。。 可以加分的

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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