/// <summary> /// 是否需要验证码 /// </summary> /// <param name="qq">QQ号</param> /// <param name="cap_cd">cap_cd</param> /// <param name="code">code</param> /// <param name="verify">verify</param> /// <returns>逻辑型</returns> public bool Is_Code(string qq, ref string cap_cd, ref string code, ref string verify) { string url = "https://ssl.ptlogin2.qq.com/check?pt_tea=2&uin=" + qq + "&appid=" + Resources.aid + "&ptlang=2052®master=&pt_uistyle=9&r=" + GetText.GenerateTimeStamp() + "&pt_jstoken=1468653375"; string temp = string.Empty; temp = WEB.GetWebData(url, ref temp, ref temp, ref temp); string [] data = GetText.TextMiddle(temp, "ptui_checkVC(", ")", 0).Replace("'", "").Split(','); if (data[0] == "0") { code = data[1]; verify = data[3]; return(false); } else if (data[0] == "1") { cap_cd = data[1]; return(true); } else { return(false); } }
/// <summary> /// 取滑块阴影坐标 /// </summary> /// <param name="sess">sess</param> /// <param name="sid">sid</param> /// <param name="vsig">vsig</param> /// <returns>整数型</returns> public static int SliderCoordinate(string sess, string sid, string vsig, int y) { System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); //查看程序耗时 stopwatch.Start(); //开始计时 string code_img_url = "https://ssl.captcha.qq.com/cap_union_new_getcapbysig?aid=" + Resources.aid + "&clientype=2&accver=1&ua=" + Resources.ua + "&ptcz=62894169db720fee1652745b0e05d87306bd4cb4a090dc5e38c561bc680764c2&fpinfo=" + Resources.fpinfo + "&tkid=1785885581&sess=" + sess + "&theme=undefined&sid=" + sid + "&showtype=popup&fb=1&forcestyle=undefined&uid=&cap_cd=&lang=2052&rnd=" + GetText.GetRandom(111111, 999999) + "&rand=" + GetText.GenerateTimeStamp() + "&vsig=" + vsig + "&img_index="; Bitmap newBmp = (Bitmap)GetImg(code_img_url + "1"); Bitmap oldBmp = (Bitmap)GetImg(code_img_url + "0"); Login.F.newBmp.Image = Image.FromHbitmap(newBmp.GetHbitmap()); Login.F.oldBmp.Image = Image.FromHbitmap(oldBmp.GetHbitmap()); for (int i = 400; i < newBmp.Width; i++) //因为腾讯的滑块没有低于450的,为了保险填400 { for (int j = y; j < y + 100; j++) //加载验证码配置的y坐标,比实际的要小100 { //获取一个点的像素的RGB的颜色 Color oldColor = oldBmp.GetPixel(i, j); Color newColor = newBmp.GetPixel(i, j); if (Math.Abs(oldColor.R - newColor.R) > 60 || Math.Abs(oldColor.G - newColor.G) > 60 || Math.Abs(oldColor.B - newColor.B) > 60) { Login.F.Log.Text += String.Format("计算 X:{0} Y:{1} 计算耗时:{2}s", i, j, stopwatch.Elapsed.TotalSeconds) + Environment.NewLine; return(i - 16); } } } return(0); }