コード例 #1
0
ファイル: TicketBuyer.cs プロジェクト: jsgydjq/train
        /// <summary>
        /// ��ȡ��֤��
        /// </summary>
        /// <param name="vCodeType"></param>
        /// <param name="queryCnt">ˢ�¼��κ�ȡ��֤��</param>
        /// <returns></returns>
        public string GetVerifyCode(VCodeType vCodeType,int queryCnt=0)
        {
            string vcode = "";
            for (int i = 0; i < queryCnt; i++)
            {
                account.GetVerifyCode(vCodeType);
            }
            while (!Stop)
            {
                try
                {
                    Image image = account.GetVerifyCode(vCodeType);

                    if (TicketSetting.AutoVCodeType == AutoVCodeType.���Զ� ||
                        TicketSetting.AutoVCodeType == AutoVCodeType.�Զ�)
                    {
                        vcode = new Cracker().Read(new Bitmap(image)); //ʶ����֤��
                        if (vcode.Length >= 4)
                        {
                            break;
                        }
                        Log(account,"��֤��ʶ�����,����");
                    }
                    if (TicketSetting.AutoVCodeType == AutoVCodeType.�˹� ||
                        TicketSetting.AutoVCodeType == AutoVCodeType.���Զ�)
                    {
                        vcode = Account.GetVCodeByForm(image);
                    }
                }catch(Exception ex)
                {
                    Log(account,ex);
                }
            }
            return vcode;
        }
コード例 #2
0
ファイル: Account.cs プロジェクト: jsgydjq/train
        /// <summary>
        /// ��ȡ��¼ʱ����֤��,�Զ����Ե��������3���������쳣
        /// </summary>
        /// <returns>����BREAK ��ʾ�û���ִֹ�� ����Ϊ��֤��ֵ</returns>
        public string GetVerifyCode(VCodeType vCodeType,ref bool auto)
        {
            //0.9789911571440171
            Random random = new Random(DateTime.Now.Millisecond);

            string url = "https://dynamic.12306.cn/otsweb/passCodeNewAction.do?module=login&rand=sjrand&" + random.NextDouble(); ;
            string referUrl = "https://dynamic.12306.cn/otsweb/loginAction.do?method=init";
            if(vCodeType==VCodeType.SubmitOrder)
            {
                url = "https://dynamic.12306.cn/otsweb/passCodeNewAction.do?module=passenger&rand=randp&" + random.NextDouble(); ;
                referUrl = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=init";
            }
            string vcode = "";
            do
            {

                Stream stream =HttpRequest.Create(url,referUrl, Cookie,HttpMethod.GET, "", Proxy).GetStream();
                Image image = Image.FromStream(stream);

                    vcode = new Cracker().Read(new Bitmap(image));
                    if (vcode.Length < 4)
                    {
                        if (auto)
                            vcode = "";
                        else
                            vcode = GetVCodeByForm(image);
                    }

                //vcode = GetVCodeByForm(image);
                if (vcode == "BREAK")
                    return "�û���ֹ";
            } while (vcode == "");
            return vcode;
        }