|
本帖最后由 zhwq107 于 2013-7-3 14:07 编辑
不知道是我自己操作有误还是有关腾讯的东东登陆起码都是这么麻烦?自己实在解决不掉,希望大家能来帮助了。问题:获取到验证码以及拿到cookies,传给登陆的post中,始终返回的是失败。网站:chuangshi.qq.com
上代码先。
验证码图片的获取,返回的cookie保存在cookies中。 - private void GetCode()
- {
- HttpItem item = new HttpItem()
- {
- URL = "http://chuangshi.qq.com/read/Public/poploginverify/1372753833331",
- Referer = "http://chuangshi.qq.com/read/public/popuplogin.html",
- Accept = "image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5",
- ResultType = ResultType.Byte
- };
- HttpHelper helper = new HttpHelper();
- HttpResult result = helper.GetHtml(item);
- cookies = result.Cookie;
- picCode.Image = byteArrayToImage(result.ResultByte);
- }
复制代码分别POST用户名密码以及验证码,读取cookies为cookie,输出返回结果到文本框。 - HttpItem item = new HttpItem()
- {
- URL = "http://chuangshi.qq.com/read/public/loginajax.html",
- Method = "post",
- Postdata = "username=" + txtUsername.Text + "&password=" + txtPassword.Text + "&autologin=false&verify=" + txtCode.Text,
- Cookie = cookies,
- Referer = "http://chuangshi.qq.com/read/public/popuplogin.html",
- Accept = "application/json, text/javascript, */*; q=0.01",
- ContentType = "application/x-www-form-urlencoded; charset=UTF-8",
- };
- item.Header.Add("X-Requested-With", "XMLHttpRequest");
- HttpHelper helper = new HttpHelper();
- HttpResult result = helper.GetHtml(item);
- txtShow.Text = result.Html;
- txtShow.AppendText(cookies);
复制代码 如此操作后,返回总是登陆失败,碰到瓶颈了,求大家帮忙了。
|
|