Esempio n. 1
0
func TestGetAttributes(t *testing.T) {
	actual := query.GetAttributes(simpleHTML, "href", "http://google.com")

	if len(actual) != 1 {
		t.Error("Expected 1 matching token")
	}
}
Esempio n. 2
0
func main() {
	html, _ := FetchURL("http://owainlewis.com")

	tokens := query.GetTokensOfType(html, "a")

	for _, token := range tokens {
		printToken(token)
	}

	attrQuery := query.GetAttributes(html, "href", "/articles")

	for _, token := range attrQuery {
		printToken(token)
	}
}