MatchElemAttr func implementation

This commit is contained in:
2026-01-16 01:13:53 +03:00
parent 78985687a1
commit 55a6a4d3ef
3 changed files with 67 additions and 3 deletions

26
match_test.go Normal file
View File

@@ -0,0 +1,26 @@
package scraper
import (
"strings"
"testing"
"golang.org/x/net/html"
)
const fragment = `<div id="main-copy"></div>`
func TestMatchElemAttr(t *testing.T) {
n, err := html.ParseFragment(strings.NewReader(fragment), body)
if err != nil {
t.Error(err)
}
n1 := n[0]
result, err := MatchElemAttr(fragment, n1)
if err != nil {
t.Error(err)
}
if !result {
t.Fail()
}
}