hocjooker@gmail.com 1 年之前
父節點
當前提交
01eb0f2a3b
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      main.go

+ 14 - 0
main.go

@@ -56,6 +56,20 @@ func main() {
 	fmt.Println("ItemPice: ", doc.Find(cItemPrice).First().Text())
 	fmt.Println("Email: ", findEmail(doc.Find(cEmail).First().Text(), ""))
 	fmt.Println("Rating : ", doc.Find(cRating).First().Text())
+
+	doc.Find("link ~ meta").Each(func(i int, s *goquery.Selection) {
+		v, _ := s.Attr("property")
+		if v == "og:description" {
+			fmt.Println("og:description : ", s.AttrOr("content", ""))
+		} else if v == "og:title" {
+			fmt.Println("og:title : ", s.AttrOr("content", ""))
+		} else if v == "og:image" {
+			fmt.Println("og:image : ", s.AttrOr("content", ""))
+		} else if v == "product:price:currency" {
+			fmt.Println("currency : ", s.AttrOr("content", ""))
+		}
+	})
+
 	fmt.Println("Author : ")
 	doc.Find(cAuthor).Each(func(index int, element *goquery.Selection) {
 		link, _ := element.Attr("href")