public bool Login(LoginModel model) { GetLoginRand(model); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters["loginUser.user_name"] = model.UserName; parameters["user.password"] = model.Password; parameters["randCode"] = model.RandCode; parameters["loginRand"] = model.LoginRand; parameters["refundFlag"] = model.RefundFlag; parameters["refundLogin"] = model.RefundLogin; parameters["nameErrorFocus"] = model.NameErrorFocus; parameters["passwordErrorFocus"] = model.PasswordErrorFocus; parameters["randErrorFocus"] = model.RandErrorFocus; string content = _client.Post( "https://dynamic.12306.cn/otsweb/loginAction.do?method=login", parameters, "https://dynamic.12306.cn/otsweb/loginAction.do?method=init"); //id_jiao_se : 39815 Regex userIDReg = new Regex("var\\s*isLogin\\s*=\\s*true\\s*;{0,1}\\s*var\\s*u_name\\s*=\\s*'(?<name>[^']*)'"); MatchCollection userIDMatchs = userIDReg.Matches(content); if (userIDMatchs.Count > 0) { return true; } return false; }
public LoginModel GetLoginModel() { string content = _client.Get("https://dynamic.12306.cn/otsweb/loginAction.do?method=init"); LoginModel model = new LoginModel(); return model; }
private void OnGet() { _12306Proxy proxy = new _12306Proxy(_client); LoadVerifyImage(); LoginModel = proxy.GetLoginModel(); this.DataContext = LoginModel; }
private void GetLoginRand(LoginModel model) { string content = _client.Post( "https://dynamic.12306.cn/otsweb/loginAction.do?method=loginAysnSuggest", "https://dynamic.12306.cn/otsweb/loginAction.do?method=init"); //{"loginRand":"392","randError":"Y"} Regex loginRandReg = new Regex("{\"loginRand\":\"(?<loginRand>\\d+)\""); MatchCollection loginRandMatchs = loginRandReg.Matches(content); if (loginRandMatchs.Count > 0) { model.LoginRand = loginRandMatchs[0].Groups["loginRand"].Value; } model.RefundLogin = "******"; model.RefundFlag = "Y"; }