|
@@ -13,6 +13,7 @@ import (
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
|
"github.com/spf13/viper"
|
|
|
"github.com/tidwall/gjson"
|
|
|
+ "go.uber.org/zap"
|
|
|
"io"
|
|
|
"mime/multipart"
|
|
|
"net/http"
|
|
@@ -81,7 +82,7 @@ func (service *crawlerService) GetLoginCookie(ctx context.Context) (string, erro
|
|
|
if err != nil {
|
|
|
return "", fmt.Errorf("操作失败: %v", err)
|
|
|
}
|
|
|
-
|
|
|
+ service.logger.WithValue(ctx, zap.Time("time0", time.Now()))
|
|
|
// 添加关键请求头
|
|
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
|
req.Header.Set("Expect", "")
|
|
@@ -103,7 +104,7 @@ func (service *crawlerService) GetLoginCookie(ctx context.Context) (string, erro
|
|
|
return "", fmt.Errorf("%v", err)
|
|
|
}
|
|
|
defer resp.Body.Close()
|
|
|
-
|
|
|
+ service.logger.WithValue(ctx, zap.Time("time1", time.Now()))
|
|
|
// 输出响应体,调试用
|
|
|
_, err = io.ReadAll(resp.Body)
|
|
|
if err != nil {
|
|
@@ -119,6 +120,7 @@ func (service *crawlerService) GetLoginCookie(ctx context.Context) (string, erro
|
|
|
cookieStr.WriteString(parts[0] + "; ")
|
|
|
}
|
|
|
}
|
|
|
+ service.logger.WithValue(ctx, zap.Time("time2", time.Now()))
|
|
|
cookieHeader := strings.TrimRight(cookieStr.String(), "; ")
|
|
|
|
|
|
if cookieHeader == "" {
|