Documentation
¶
Index ¶
- func ParseHTML(body []byte) (*goquery.Document, error)
- type HTMLElement
- func (he HTMLElement) Attr(key string) string
- func (he HTMLElement) Child(selector string, num int) *HTMLElement
- func (he HTMLElement) ChildAttr(selector, attrName string) string
- func (he HTMLElement) ChildText(selector string) string
- func (he HTMLElement) ChildrenAttr(selector, attrName string) []string
- func (he HTMLElement) ChildrenText(selector string) []string
- func (he HTMLElement) Each(selector string, callback func(int, *HTMLElement))
- func (he HTMLElement) FirstChild(selector string) *HTMLElement
- func (he HTMLElement) InnerHTML() (string, error)
- func (he HTMLElement) LastChild(selector string) *HTMLElement
- func (he HTMLElement) OuterHTML() (string, error)
- func (he HTMLElement) Parent() *HTMLElement
- func (he HTMLElement) Parents() []*HTMLElement
- func (he HTMLElement) Text() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTMLElement ¶
type HTMLElement struct {
// Name is the name of the tag
Name string
// DOM is the goquery parsed DOM object of the page. DOM is relative
// to the current HTMLElement
DOM *goquery.Selection
// Index stores the position of the current element within
// all the elements matched by an OnHTML callback
Index int
Node *html.Node
}
HTMLElement is the representation of a HTML tag.
func NewHTMLElementFromSelectionNode ¶
NewHTMLElementFromSelectionNode creates a HTMLElement from a goquery.Selection Node.
func (HTMLElement) Attr ¶
func (he HTMLElement) Attr(key string) string
Attr returns the selected attribute of a HTMLElement or empty string if no attribute found
func (HTMLElement) Child ¶
func (he HTMLElement) Child(selector string, num int) *HTMLElement
Child returns the numth matched child element. num starts at 1, not at 0.
func (HTMLElement) ChildAttr ¶
func (he HTMLElement) ChildAttr(selector, attrName string) string
ChildAttr returns the stripped text content of the first matching element's attribute.
func (HTMLElement) ChildText ¶
func (he HTMLElement) ChildText(selector string) string
ChildText returns the concatenated and stripped text content of the matching elements.
func (HTMLElement) ChildrenAttr ¶
func (he HTMLElement) ChildrenAttr(selector, attrName string) []string
ChildrenAttr returns the stripped text content of all the matching element's attributes.
func (HTMLElement) ChildrenText ¶
func (he HTMLElement) ChildrenText(selector string) []string
ChildrenText returns the stripped text content of all the matching elements.
func (HTMLElement) Each ¶
func (he HTMLElement) Each(selector string, callback func(int, *HTMLElement))
Each iterates over the elements matched by the first argument and calls the callback function on every HTMLElement match.
func (HTMLElement) FirstChild ¶
func (he HTMLElement) FirstChild(selector string) *HTMLElement
FirstChild returns the first child element that matches the selector.
func (HTMLElement) InnerHTML ¶
func (he HTMLElement) InnerHTML() (string, error)
InnerHTML gets the HTML contents of the first element in the set of matched elements. It includes text and comment nodes.
func (HTMLElement) LastChild ¶
func (he HTMLElement) LastChild(selector string) *HTMLElement
LastChild returns the last child element that matches the selector.
func (HTMLElement) OuterHTML ¶
func (he HTMLElement) OuterHTML() (string, error)
OuterHtml returns the outer HTML rendering of the first item in the selection - that is, the HTML including the first element's tag and attributes.
func (HTMLElement) Parent ¶
func (he HTMLElement) Parent() *HTMLElement
Parent returns the direct parent element.
func (HTMLElement) Parents ¶
func (he HTMLElement) Parents() []*HTMLElement
Parents returns all parent elements.
func (HTMLElement) Text ¶
func (he HTMLElement) Text() string
Text gets the combined text contents of each element in the set of matched elements, including their descendants.