bobg / htree

Tools for working with trees of html.Nodes.

Home Page:https://godoc.org/github.com/bobg/htree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Htree - Go package for working with html.Node trees

Go Reference Go Report Card Tests Coverage Status Mentioned in Awesome Go

This is htree, a Go package that helps traverse, navigate, filter, and otherwise process trees of html.Node objects.

Usage

root, err := html.Parse(input)
if err != nil { ... }

body := htree.FindEl(root, func(n *html.Node) bool {
  return n.DataAtom == atom.Body
})

content := htree.FindEl(body, func(n *html.Node) bool {
  return n.DataAtom == atom.Div && htree.ElClassContains(n, "content")
})

...etc...

About

Tools for working with trees of html.Nodes.

https://godoc.org/github.com/bobg/htree

License:MIT License


Languages

Language:HTML 98.0%Language:Go 2.0%