✨ resolved #169
This commit is contained in:
parent
5500980d63
commit
e31402e94f
@ -271,18 +271,25 @@ func (c Cloud189) Login(account *model.Account) error {
|
|||||||
client.SetRetryCount(3)
|
client.SetRetryCount(3)
|
||||||
}
|
}
|
||||||
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action"
|
||||||
res, err := client.R().Get(url)
|
b := ""
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b := res.String()
|
|
||||||
lt := ""
|
lt := ""
|
||||||
ltText := regexp.MustCompile(`lt = "(.+?)"`)
|
ltText := regexp.MustCompile(`lt = "(.+?)"`)
|
||||||
ltTextArr := ltText.FindStringSubmatch(b)
|
for i := 0; i < 3; i++ {
|
||||||
if len(ltTextArr) > 0 {
|
res, err := client.R().Get(url)
|
||||||
lt = ltTextArr[1]
|
if err != nil {
|
||||||
} else {
|
return err
|
||||||
return fmt.Errorf("ltTextArr = 0")
|
}
|
||||||
|
b = res.String()
|
||||||
|
ltTextArr := ltText.FindStringSubmatch(b)
|
||||||
|
if len(ltTextArr) > 0 {
|
||||||
|
lt = ltTextArr[1]
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
<-time.After(time.Second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lt == "" {
|
||||||
|
return fmt.Errorf("get empty login page")
|
||||||
}
|
}
|
||||||
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
captchaToken := regexp.MustCompile(`captchaToken' value='(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]
|
||||||
@ -298,7 +305,7 @@ func (c Cloud189) Login(account *model.Account) error {
|
|||||||
passwordRsa := RsaEncode([]byte(account.Password), jRsakey)
|
passwordRsa := RsaEncode([]byte(account.Password), jRsakey)
|
||||||
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
url = "https://open.e.189.cn/api/logbox/oauth2/loginSubmit.do"
|
||||||
var loginResp LoginResp
|
var loginResp LoginResp
|
||||||
res, err = client.R().
|
res, err := client.R().
|
||||||
SetHeaders(map[string]string{
|
SetHeaders(map[string]string{
|
||||||
"lt": lt,
|
"lt": lt,
|
||||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user