tuananhvp25081995 1 year ago
parent
commit
c8b79d7a64
1 changed files with 13 additions and 11 deletions
  1. 13 11
      main.go

+ 13 - 11
main.go

@@ -5,6 +5,7 @@ import (
 	"log"
 	"net/http"
 	"regexp"
+	"strings"
 
 	"github.com/PuerkitoBio/goquery"
 )
@@ -13,7 +14,7 @@ func main() {
 	// Wordpress
 	// url := "https://addand.kr/shop/new-%ed%95%9c-%ea%b6%8c%ec%9c%bc%eb%a1%9c-%eb%81%9d%eb%82%98%eb%8a%94-%eb%85%b8%ec%85%98/"
 
-	url := "https://droppii.net.vn/cnd-ginseng-gold"
+	url := "https://www.youngla.com/products/yla-ftshorts-black"
 	// Send an HTTP GET request to the URL
 	response, err := http.Get(url)
 	if err != nil {
@@ -27,17 +28,17 @@ func main() {
 	}
 
 	// These will the value of PDP parsing structures
-	cItemName := ".product_title"
-	cShortDesc := ".woocommerce-product-details__short-description"
+	cItemName := ".ProductMeta__Title.Heading.u-h2"
+	cShortDesc := ".shopify-installments span#shopify-installments-content"
 	cItemCategory := ".single-breadcrumbs-wrapper"
 
 	cItemTags := ".tagged_as"
-	cItemImages := ".woocommerce-product-gallery__image a"
-	cItemTextDesc := "div.product-tabs-wrapper"
-	// cItemOptions := "select#rating option"
-	cItemPrice := ".summary>.summary-inner>.price .woocommerce-Price-amount.amount"
+	cItemImages := ".AspectRatio.AspectRatio--withFallback img"
+	cItemTextDesc := ".ProductMeta__Description"
+	// // cItemOptions := "select#rating option"
+	cItemPrice := ".ProductMeta>.ProductMeta__PriceList.Heading>.ProductMeta__Price.Price.Text--subdued.u-h4"
 	cEmail := "footer"
-	cAddress := ".elementor-widget-container > p"
+	cInfo := ".Footer__Block.Footer__Block--text>.Footer__Content.Rte > p"
 	cRating := ".star-rating .rating"
 	cAuthor := ".product-brand a"
 	cVideo := "iframe"
@@ -50,7 +51,7 @@ func main() {
 	fmt.Println("TextDesc: ", doc.Find(cItemTextDesc).First().Text())
 	fmt.Println("ItemPice: ", doc.Find(cItemPrice).First().Text())
 	fmt.Println("Email: ", findEmail(doc.Find(cEmail).First().Text(), ""))
-	fmt.Println("Address: ", doc.Find(cAddress).First().Text())
+	fmt.Println("Info: ", doc.Find(cInfo).First().Text())
 
 	fmt.Println("Rating : ", doc.Find(cRating).First().Text())
 
@@ -77,8 +78,9 @@ func main() {
 	imgs := []string{}
 	fmt.Println("ItemImages: ")
 	doc.Find(cItemImages).Each(func(index int, element *goquery.Selection) {
-		img, _ := element.Attr("href")
-		imgs = append(imgs, img)
+		img, _ := element.Attr("data-original-src")
+		res := strings.ReplaceAll(img, "//", "https://")
+		imgs = append(imgs, res)
 	})
 	fmt.Println("", imgs)