gDom

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalysisTag

func AnalysisTag(node *html.Node, items *[]ContentItem)

解析标签

func FindNode

func FindNode(node *html.Node, nodeType html.NodeType, tagName string) (*html.Node, error)

查找单一节点

func FindNodes

func FindNodes(node *html.Node, nodeType html.NodeType, tagName string, nodes *[]*html.Node)

查找对应标签的全部节点

func Href

func Href(node *html.Node) string

获取 href 属性

func InitByContent

func InitByContent(htmlContent string) (*html.Node, error)

从内容初始化 HTML 对象

func InitByFile

func InitByFile(filePath string) (*html.Node, error)

从一个文件初始化 HTML 对象

func InitByUrl

func InitByUrl(url string) (*html.Node, error)

从 url 初始化 HTML 对象

func Src

func Src(node *html.Node) string

获取 src 属性

func TransformHTMLToItems

func TransformHTMLToItems(parentNode *html.Node, items *[]ContentItem)

将 html 源码转换为项目数组

func TransformItemsToHtml

func TransformItemsToHtml(items []ContentItem) string

将项目转化为html形式

Types

type ContentItem

type ContentItem struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

type Html

type Html struct {
	HTMLNode *html.Node
	Body     *html.Node
	Items    []ContentItem
}

Jump to

Keyboard shortcuts

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