| 用万能框架dll写一个网站自动登录的软件,一直提示验证码错误,流程如下:1、先获取验证码和cookie;2、用cookie提交登录。 获取验证码的代码如下:
 
 [C#] 纯文本查看 复制代码             Shanqiu sq = new Shanqiu();
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "https://xxxxx.com/code?_=" + sq.GetTimeStampMsOF(),
                Method = "GET",
            };
            Image img = http.GetImage(item);
            pictureBox1.Image = img;
            HttpResult result = http.GetHtml(item);
            myCookie = result.Cookie;
 sq.GetTimeStampMsOF是我自己写的一个类,主要用来获取时间戳
 
 登录的代码如下:
 
 [C#] 纯文本查看 复制代码             string u = txtUsername.Text.Trim();
            string p = txtPassword.Text.Trim();
            string v = txtValidate.Text.Trim();
            string data = "type=1&account=" + u + "&password=" + p + "&code=" + v;
            
            HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "https://xxxx.com/login",
                Method = "POST",
                ContentType = "application/x-www-form-urlencoded",
                PostEncoding = Encoding.UTF8,
                Postdata = data,
                Referer = "https://xxxx.com/login",
                Cookie = myCookie,
            };
            Console.WriteLine(Encoding.UTF8);
            HttpResult result = http.GetHtml(item);
            string cookie = result.Cookie;
            Console.WriteLine(result.Header);
 myCookie是全局变量,用来存储获取验证码时的cookie。
 
 因为隐私问题我把URL用XXXX.com来代替。
 返回的头信息显示验证码错误,请问各位大神知道是哪里出错吗?
 
 |