Skip to content

Instantly share code, notes, and snippets.

@Adron
Created Jul 3, 2019
Embed
What would you like to do?
The Visit Function.
func visit(links []string, n *html.Node) []string {
if n.Type == html.ElementNode && n.Data == "a" {
for _, a := range n.Attr {
if a.Key == "href" {
links = append(links, a.Val)
}
}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
links = visit(links, c)
}
return links
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment