github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/html/get_inner_text_all.go (about) 1 package html 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/drivers" 7 "github.com/MontFerret/ferret/pkg/runtime/core" 8 "github.com/MontFerret/ferret/pkg/runtime/values" 9 ) 10 11 // INNER_TEXT_ALL returns an array of inner text of matched elements. 12 // @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node. 13 // @param {String} selector - String of CSS selector. 14 // @return {String[]} - An array of inner text if all matched elements, otherwise empty array. 15 func GetInnerTextAll(ctx context.Context, args ...core.Value) (core.Value, error) { 16 err := core.ValidateArgs(args, 2, 2) 17 18 if err != nil { 19 return values.None, err 20 } 21 22 el, err := drivers.ToElement(args[0]) 23 24 if err != nil { 25 return values.None, err 26 } 27 28 selector, err := drivers.ToQuerySelector(args[1]) 29 30 if err != nil { 31 return values.None, err 32 } 33 34 return el.GetInnerTextBySelectorAll(ctx, selector) 35 }