pars

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

README

pars

a simple html parser for go, built around golang.org/x/net/html

Installation

go get -u github.com/ubbeg2000/pars

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatClassList

func FormatClassList(classList string) string

func ParseAttributes

func ParseAttributes(z *html.Tokenizer) map[string]string

func ParseSelector

func ParseSelector(selector string) (string, string, string)

Types

type DOM

type DOM struct {
	Doctype string
	Tree    *DOMNode
	Ids     map[string]*DOMNode
	Tags    map[string][]*DOMNode
	Classes map[string][]*DOMNode
}

func ParseToDOM

func ParseToDOM(reader io.Reader) DOM

func (DOM) GetElementByID

func (d DOM) GetElementByID(id string) *DOMNode

func (DOM) GetElementsByClassName

func (d DOM) GetElementsByClassName(class string) []*DOMNode

func (DOM) GetElementsByTagName

func (d DOM) GetElementsByTagName(tag string) []*DOMNode

func (*DOM) RegisterToMaps

func (d *DOM) RegisterToMaps(nd *DOMNode)

func (DOM) Render

func (d DOM) Render() string

func (DOM) Traverse

func (d DOM) Traverse(cb func(el DOMNode))

type DOMNode

type DOMNode struct {
	TagName      string
	Text         string
	Parent       *DOMNode
	Children     []*DOMNode
	Attributes   map[string]string
	SelfEnclosed bool
}

func (*DOMNode) AppendChild

func (d *DOMNode) AppendChild(nd *DOMNode)

func (DOMNode) GetElementByID

func (d DOMNode) GetElementByID(id string) *DOMNode

func (DOMNode) GetElementsByClassName

func (d DOMNode) GetElementsByClassName(class string) []*DOMNode

func (DOMNode) GetElementsByTagName

func (d DOMNode) GetElementsByTagName(tag string) []*DOMNode

func (DOMNode) GetText

func (d DOMNode) GetText() string

func (DOMNode) QuerySelector

func (d DOMNode) QuerySelector(selector string) []*DOMNode

func (DOMNode) Render

func (d DOMNode) Render() string

func (DOMNode) String

func (d DOMNode) String() string

func (DOMNode) Traverse

func (d DOMNode) Traverse(cb func(el DOMNode))

type LinearDOM

type LinearDOM struct {
	Content []*LinearDOMElement
}

func ParseToLinear

func ParseToLinear(res io.Reader) LinearDOM

func (LinearDOM) GetElementByID

func (ld LinearDOM) GetElementByID(id string) *LinearDOMElement

func (LinearDOM) GetElementsByClassName

func (ld LinearDOM) GetElementsByClassName(class string) []*LinearDOMElement

func (LinearDOM) GetElementsByTagName

func (ld LinearDOM) GetElementsByTagName(tag string) []*LinearDOMElement

func (LinearDOM) QuerySelector

func (d LinearDOM) QuerySelector(selector string) []*LinearDOMElement

func (LinearDOM) Traverse

func (ld LinearDOM) Traverse(cb func(el LinearDOMElement))

type LinearDOMElement

type LinearDOMElement struct {
	TagName      string
	Text         string
	Attributes   map[string]string
	SelfEnclosed bool
}

func (LinearDOMElement) GetText

func (d LinearDOMElement) GetText() string

func (LinearDOMElement) String

func (d LinearDOMElement) String() string

Jump to

Keyboard shortcuts

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