Ver Fonte

GetError

1 há 2 semanas atrás
pai
commit
1603143376
2 ficheiros alterados com 23 adições e 0 exclusões
  1. 9 0
      common/period.go
  2. 14 0
      common/rod_utils.go

+ 9 - 0
common/period.go

@@ -431,3 +431,12 @@ func IsJdSb(period string) bool {
 func GetMonthEnd(t time.Time) time.Time {
 	return t.AddDate(0, 1, -t.Day())
 }
+
+func GetCurrentDate1() string {
+	tm := time.Unix(time.Now().Unix(), 0)
+	currentYear, currentMonth, _ := tm.Date()
+	currentLocation := tm.Location()
+	firstOfMonth := time.Date(currentYear, currentMonth, 10, 0, 0, 0, 0, currentLocation)
+	period := firstOfMonth.AddDate(0, 0, 0).Format("2006-01") // 当前日期
+	return period
+}

+ 14 - 0
common/rod_utils.go

@@ -604,3 +604,17 @@ func MustNext2Text(page *rod.Page, xpath string) string {
 	}
 	return x.MustNext().MustNext().MustText()
 }
+
+// 拦截
+func HijackReq(page *rod.Page, uri, xPath string) []byte {
+	ch := make(chan []byte)
+	r := PageHijackReq(page, uri, ch)
+	MustElementX(page, xPath).MustClick()
+	data, err := GetHijackResp(ch, 10)
+	if err != nil {
+		zaplog.LoggerS.Info(string(data))
+		panic(taxerr.NewWebStuckTitle(false))
+	}
+	_ = r.Stop()
+	return data
+}