public static LoginResult Login(string username, string password, LoginCheckResult checkResult)
        {
            var result = new LoginResult();

            try
            {
                using (var wc = new CookieAwareWebClient())
                {
                    wc.Cookies.Add(checkResult.baiduid);
                    var ltoken = checkResult.ltoken;
                    var lstr   = "loginmerge=true&token=" + ltoken + "&tpl=netdisk&username="******"&password="******"&codestring=" + checkResult.codeString + "&verifycode=" + Uri.EscapeDataString(checkResult.verifyCode);
                    }
                    wc.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
                    var str   = Encoding.UTF8.GetString(wc.UploadData("https://passport.baidu.com/v2/api/?login", Encoding.UTF8.GetBytes(lstr)));
                    var match = Regex.Match(str, "error=(\\d+)");
                    var errno = match.Success ? int.Parse(match.Groups[1].Value) : 0;
                    if (errno != 0)
                    {
                        result.exception = new Exception("Login returned error = " + errno);
                        result.errno     = errno;
                    }
                    else
                    {
                        str = wc.DownloadString("https://passport.baidu.com/v3/login/api/auth/?return_type=3&tpl=netdisk&u=http%3A%2F%2Fpan.baidu.com%2Fdisk%2Fhome");
                        long uid = 0;
                        match = Regex.Match(str, "\"uk\"\\s*:\\s*(\\d+)");
                        if (match.Success)
                        {
                            long.TryParse(match.Groups[1].Value, out uid);
                        }
                        string baiduid = null, bduss = null, stoken = null;
                        foreach (Cookie cookie in wc.Cookies.GetAllCookies())
                        {
                            if (cookie.Name.ToLower() == "baiduid")
                            {
                                baiduid = cookie.Value;
                            }
                            else if (cookie.Name.ToLower() == "bduss")
                            {
                                bduss = cookie.Value;
                            }
                            else if (cookie.Name.ToLower() == "stoken" && cookie.Domain.ToLower().Contains("pan."))
                            {
                                stoken = cookie.Value;
                            }
                        }
                        if (baiduid != null && bduss != null && stoken != null)
                        {
                            result.credential = new Credential(baiduid, bduss, stoken, uid);
                            result.success    = true;
                        }
                        else
                        {
                            result.exception = new Exception("Cannot find required cookies.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.exception = ex;
            }
            return(result);
        }