Пример #1
0
// grab text of matching selector, return as one line
func sectionFromElement(root *html.Node, sel cascadia.Selector) string {
	el := sel.MatchFirst(root)
	if el == nil {
		return ""
	}
	return compressSpace(getTextContent(el))
}
Пример #2
0
// getElemText returns the innerText of the selected node.
func getElemText(n *html.Node, sel cascadia.Selector) string {
	if node := sel.MatchFirst(n); node != nil {
		return htmlutil.InnerText(node)
	}
	return ""
}