Created
December 29, 2022 13:19
-
-
Save robsongomes/f621894901817d28c7a1fcd45b987c47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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