Skip to content

Instantly share code, notes, and snippets.

@robsongomes
Created December 29, 2022 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsongomes/f621894901817d28c7a1fcd45b987c47 to your computer and use it in GitHub Desktop.
Save robsongomes/f621894901817d28c7a1fcd45b987c47 to your computer and use it in GitHub Desktop.
func main() {
f, err := os.Open("index.html")
if err != nil {
log.Fatal(err)
}
z := html.NewTokenizer(f)
for {
tt := z.Next()
switch tt {
case html.ErrorToken:
return
case html.SelfClosingTagToken:
case html.StartTagToken:
token := z.Token()
if token.Data == "a" {
tt = z.Next()
if tt == html.TextToken {
fmt.Println(token)
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment