Ver Fonte

补充申报方法

1 há 2 semanas atrás
pai
commit
e6c1c51d0e
1 ficheiros alterados com 20 adições e 0 exclusões
  1. 20 0
      common/rod_utils.go

+ 20 - 0
common/rod_utils.go

@@ -575,3 +575,23 @@ func WaitHasX10(page *rod.Page, xpath string) (x bool) {
 	}
 	return x
 }
+
+// 返回当前元素下一个元素的text 如果没有元素就直接返回空
+func MustNextText(page *rod.Page, xpath string) string {
+	x := MustElementXV(page, xpath)
+	if x == nil {
+		return ""
+	}
+	return x.MustNext().MustText()
+}
+
+// 2033年12月31日 // 2033-12-31
+func DataFormat(data string) string {
+	strings.ReplaceAll(data, "年", "-")
+	strings.ReplaceAll(data, "月", "-")
+	strings.ReplaceAll(data, "日", "")
+	if len(data) > 10 {
+		data = data[:10]
+	}
+	return data
+}