fix(189): new resty client
This commit is contained in:
parent
6a7eb8b3eb
commit
62aefc4f68
@ -17,7 +17,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -94,18 +93,11 @@ type LoginResp struct {
|
|||||||
|
|
||||||
// Login refer to PanIndex
|
// Login refer to PanIndex
|
||||||
func (driver Cloud189) Login(account *model.Account) error {
|
func (driver Cloud189) Login(account *model.Account) error {
|
||||||
client, ok := client189Map[account.Name]
|
client := resty.New()
|
||||||
if !ok {
|
//client.SetCookieJar(cookieJar)
|
||||||
//cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
client.SetTimeout(base.DefaultTimeout)
|
||||||
client = resty.New()
|
client.SetRetryCount(3)
|
||||||
//client.SetCookieJar(cookieJar)
|
client.SetHeader("Referer", "https://cloud.189.cn/")
|
||||||
client.SetTimeout(base.DefaultTimeout)
|
|
||||||
client.SetRetryCount(3)
|
|
||||||
client.SetHeader("Referer", "https://cloud.189.cn/")
|
|
||||||
}
|
|
||||||
// clear cookie
|
|
||||||
jar, _ := cookiejar.New(nil)
|
|
||||||
client.SetCookieJar(jar)
|
|
||||||
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"
|
||||||
b := ""
|
b := ""
|
||||||
lt := ""
|
lt := ""
|
||||||
@ -131,7 +123,8 @@ func (driver Cloud189) Login(account *model.Account) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lt == "" {
|
if lt == "" {
|
||||||
return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s", b, res.StatusCode(), res.RawResponse.Request.URL.String())
|
return fmt.Errorf("get page: %s \nstatus: %d \nrequest url: %s\nredirect url: %s",
|
||||||
|
b, res.StatusCode(), res.RawResponse.Request.URL.String(), res.Header().Get("location"))
|
||||||
}
|
}
|
||||||
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]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user