package main import ( "fmt" "log" "net/http" "github.com/PuerkitoBio/goquery" ) 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/" // Replace with the URL of your choice // Send an HTTP GET request to the URL response, err := http.Get(url) if err != nil { log.Fatal(err) } defer response.Body.Close() doc, err := goquery.NewDocumentFromReader(response.Body) if err != nil { log.Fatal(err) } // These will the value of PDP parsing structures cItemName := ".product_title" cShortDesc := ".woocommerce-product-details__short-description" cItemCategory := ".posted_in" cItemTags := ".tagged_as" cItemImages := ".woocommerce-product-gallery__image" // Use the Find method to select elements that match the css selector // doc.Find(cItemName).Each(func(index int, element *goquery.Selection) { // // Extract the text associated with the selected element // text := element.Text() // fmt.Printf("Text associated with %s: %s\n", cItemName, text) // }) fmt.Println("ItemName: ", doc.Find(cItemName).First().Text()) fmt.Println("ShortDesc: ", doc.Find(cShortDesc).First().Text()) fmt.Println("ItemCategory: ", doc.Find(cItemCategory).First().Text()) fmt.Println("ItemTags: ", doc.Find(cItemTags).First().Text()) doc.Find(cItemImages).Each(func(index int, element *goquery.Selection) { href, _ := element.Attr("href") fmt.Printf("ItemImages: %s\n", href) }) }