go-extractor/nodes.go

33 lines
448 B
Go

package extractor
type Nodes []Node
func (n Nodes) Select(selector string) Nodes {
var res Nodes
for _, node := range n {
res = append(res, node.Select(selector)...)
}
return res
}
func (d Nodes) First() Node {
return d[0]
}
func (d Nodes) ExtractText() ([]string, error) {
var res []string
for _, doc := range d {
text, err := doc.Text()
if err != nil {
return nil, err
}
res = append(res, text)
}
return res, nil
}