From 62aefc4f6826b88a4881627555c1ee93a14de188 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Sat, 28 May 2022 20:43:13 +0800 Subject: [PATCH] fix(189): new resty client --- drivers/189/189.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/189/189.go b/drivers/189/189.go index ac6ea189..069c13cd 100644 --- a/drivers/189/189.go +++ b/drivers/189/189.go @@ -17,7 +17,6 @@ import ( "io" "math" "net/http" - "net/http/cookiejar" "regexp" "strconv" "strings" @@ -94,18 +93,11 @@ type LoginResp struct { // Login refer to PanIndex func (driver Cloud189) Login(account *model.Account) error { - client, ok := client189Map[account.Name] - if !ok { - //cookieJar, _ := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List}) - client = resty.New() - //client.SetCookieJar(cookieJar) - client.SetTimeout(base.DefaultTimeout) - client.SetRetryCount(3) - client.SetHeader("Referer", "https://cloud.189.cn/") - } - // clear cookie - jar, _ := cookiejar.New(nil) - client.SetCookieJar(jar) + client := resty.New() + //client.SetCookieJar(cookieJar) + client.SetTimeout(base.DefaultTimeout) + client.SetRetryCount(3) + client.SetHeader("Referer", "https://cloud.189.cn/") url := "https://cloud.189.cn/api/portal/loginUrl.action?redirectURL=https%3A%2F%2Fcloud.189.cn%2Fmain.action" b := "" lt := "" @@ -131,7 +123,8 @@ func (driver Cloud189) Login(account *model.Account) error { } } 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] returnUrl := regexp.MustCompile(`returnUrl = '(.+?)'`).FindStringSubmatch(b)[1]