search_node.go
This commit is contained in:
10
match.go
10
match.go
@@ -1,3 +1,4 @@
|
||||
//go:build ignore
|
||||
package scraper
|
||||
|
||||
import (
|
||||
@@ -17,7 +18,7 @@ var body = &html.Node{
|
||||
|
||||
var ErrNotAnElementNode = errors.New("not a html.ElementNode")
|
||||
|
||||
func parseFragment(s string) (*html.Node, error) {
|
||||
func ParseFragment(s string) (*html.Node, error) {
|
||||
n, err := html.ParseFragment(strings.NewReader(s), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -33,13 +34,13 @@ func MatchElemAttr(s string, n *html.Node) (bool, error) {
|
||||
|
||||
if n1.Type != html.ElementNode {
|
||||
return false, errors.Join(
|
||||
ErrNotAnElementNode,
|
||||
ErrNotAnElementNode,
|
||||
errors.New("s isn's a html.ElementNode"),
|
||||
)
|
||||
)
|
||||
}
|
||||
if n.Type != html.ElementNode {
|
||||
return false, errors.Join(
|
||||
ErrNotAnElementNode,
|
||||
ErrNotAnElementNode,
|
||||
errors.New("n isn's a html.ElementNode"),
|
||||
)
|
||||
}
|
||||
@@ -51,7 +52,6 @@ func MatchElemAttr(s string, n *html.Node) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
func SearchElemAttr2(s string, n2 *html.Node) (chan *html.Node, error) {
|
||||
ch := make(chan *html.Node)
|
||||
var crawl func(*html.Node)
|
||||
|
||||
Reference in New Issue
Block a user