html

package
v0.1.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseHTML

func ParseHTML(body []byte) (*goquery.Document, error)

ParseHTML 解析 html

Types

type HTMLElement

type HTMLElement struct {
	Name  string
	DOM   *goquery.Selection
	Index int
	Node  *html.Node
}

func NewHTMLElementFromSelectionNode

func NewHTMLElementFromSelectionNode(s *goquery.Selection, n *html.Node, index int) *HTMLElement

NewHTMLElementFromSelectionNode 创建一个元素

func (HTMLElement) Attr

func (he HTMLElement) Attr(key string) string

Attr 获取 HTML 元素的一个属性值

func (HTMLElement) Child

func (he HTMLElement) Child(selector string, num int) *HTMLElement

Child 返回第 num 个匹配选择器的子元素,num 不是索引,而是从 1 开始的顺序号

func (HTMLElement) ChildAttr

func (he HTMLElement) ChildAttr(selector, attrName string) string

ChildAttr 在当前元素内部根据选择器查找元素,并返回第一个匹配的目标元素的属性值

func (HTMLElement) ChildText

func (he HTMLElement) ChildText(selector string) string

ChildText 在当前元素内部根据选择器查找元素,并返回第一个匹配的目标元素的文本内容

func (HTMLElement) ChildrenAttr

func (he HTMLElement) ChildrenAttr(selector, attrName string) []string

ChildrenAttr 在当前元素内部根据选择器查找元素,并返回全部匹配的目标元素的属性值切片

func (HTMLElement) ChildrenText

func (he HTMLElement) ChildrenText(selector string) []string

ChildrenText 在当前元素内部根据选择器查找元素,并返回全部匹配的目标元素的文本切片

func (HTMLElement) Each

func (he HTMLElement) Each(selector string, callback func(int, *HTMLElement))

Each 处理每一个与选择器匹配的元素

func (HTMLElement) FirstChild

func (he HTMLElement) FirstChild(selector string) *HTMLElement

FirstChild 返回第一个匹配选择器的子元素

func (HTMLElement) InnerHTML

func (he HTMLElement) InnerHTML() (string, error)

InnerHTML 当前元素的内部 HTML 代码

func (HTMLElement) LastChild

func (he HTMLElement) LastChild(selector string) *HTMLElement

LastChild 返回最后一个匹配选择器的子元素

func (HTMLElement) OuterHTML

func (he HTMLElement) OuterHTML() (string, error)

OuterHTML 当前元素的整体 HTML 代码

func (HTMLElement) Text

func (he HTMLElement) Text() string

Text 当前元素的所有文本(包括子元素)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL