Awesome
htmlx
htmlx is a library which provides a set of extensions on go's golang.org/x/net/html
library.
// parse html file
doc, err := htmlx.Load("test.html")
if err != nil {
panic(err)
}
div := doc.Find(htmlx.ID("test"))
for _, a := range div.FindAll(htmlx.TagName("a")) {
if href, ok := a.Attr("href"); ok {
fmt.Println(href)
}
}
err = div.SetHTML(`<em>no links</em>`)
if err != nil {
panic(err)
}
fmt.Println("html:", div)