doc, _ := goquery.NewDocument(html) element := doc.Find("#myID") text := element.Text() fmt.Println(text)
doc, _ := goquery.NewDocument(html) doc.Find("a").Each(func(i int, s *goquery.Selection) { url, _ := s.Attr("href") fmt.Printf("Link %d: %s\n", i, url) })This example selects all links in the HTML document using the Find method and iterates over them using the Each method. The Attr method is used to extract the "href" attribute of each link and print it. Package Library: The package "github.com/PuerkitoBio/goquery" provides a set of functions and methods to manipulate HTML documents using CSS selectors. It is a third-party package and not a part of the standard Go library.