rdluck 4 years ago
parent
commit
cfbfb8b379
1 changed files with 21 additions and 1 deletions
  1. 21 1
      services/article.go

+ 21 - 1
services/article.go

@@ -42,6 +42,7 @@ func GetReportContentTextSub(content string) (contentSub string, err error) {
 	}
 	}
 	n := 0
 	n := 0
 	doc.Find("p").Each(func(i int, s *goquery.Selection) {
 	doc.Find("p").Each(func(i int, s *goquery.Selection) {
+
 		if n > 3 {
 		if n > 3 {
 			return
 			return
 		}
 		}
@@ -56,6 +57,25 @@ func GetReportContentTextSub(content string) (contentSub string, err error) {
 		//	contentSub = contentSub + "<p>" + phtml + "</p>"
 		//	contentSub = contentSub + "<p>" + phtml + "</p>"
 		//}
 		//}
 	})
 	})
+
+	if contentSub == "" {
+		m := 0
+		doc.Find("p").Each(func(i int, s *goquery.Selection) {
+			if m > 3 {
+				return
+			}
+			m++
+			contentSub = contentSub + s.Text()
+			//phtml, err := s.Html()
+			//if err != nil {
+			//	fmt.Println("get html err", err.Error())
+			//	return
+			//}
+			//if s.Text() != "" || !strings.Contains(phtml, "src") {
+			//	contentSub = contentSub + "<p>" + phtml + "</p>"
+			//}
+		})
+	}
 	return
 	return
 }
 }
 
 
@@ -88,7 +108,7 @@ func GetArticleExpert() {
 		if strings.Contains(contentTxt, "#专家评价") || strings.Contains(contentTxt, "专家评价") {
 		if strings.Contains(contentTxt, "#专家评价") || strings.Contains(contentTxt, "专家评价") {
 			expertContent := s.Next().Text()
 			expertContent := s.Next().Text()
 			if expertContent == "" {
 			if expertContent == "" {
-				expertContent=contentTxt
+				expertContent = contentTxt
 			}
 			}
 			if expertContent != "" {
 			if expertContent != "" {
 				rightIndex := strings.Index(expertContent, ")")
 				rightIndex := strings.Index(expertContent, ")")