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) Children(selector string) []*HTMLElement
- 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) bool)
- func (he *HTMLElement) FindChildByStripedText(selector, text string) *HTMLElement
- func (he *HTMLElement) FindChildByText(selector, text string) *HTMLElement
- func (he *HTMLElement) FindChildrenByStripedText(selector, text string) []*HTMLElement
- func (he *HTMLElement) FindChildrenByText(selector, text string) []*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) Children ¶ added in v0.2.4
func (he *HTMLElement) Children(selector string) []*HTMLElement
Children returns all child elements matching the selector
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) bool)
Each iterates over the elements matched by the first argument and calls the callback function on every HTMLElement match.
The for loop will break when the `callback` returns `true`.
func (*HTMLElement) FindChildByStripedText ¶ added in v0.2.2
func (he *HTMLElement) FindChildByStripedText(selector, text string) *HTMLElement
FindChildByStripedText returns the first child element matching the stripped text.
func (*HTMLElement) FindChildByText ¶ added in v0.2.2
func (he *HTMLElement) FindChildByText(selector, text string) *HTMLElement
FindChildByText returns the first child element matching the target text.
func (*HTMLElement) FindChildrenByStripedText ¶ added in v0.2.2
func (he *HTMLElement) FindChildrenByStripedText(selector, text string) []*HTMLElement
FindChildrenByStripedText returns all the child elements matching the stripped text.
func (*HTMLElement) FindChildrenByText ¶ added in v0.2.2
func (he *HTMLElement) FindChildrenByText(selector, text string) []*HTMLElement
FindChildrenByText returns all the child elements matching the target text.
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.