html

package
v0.0.0-...-8693642 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// ID is an arbitrary value that is primarily used for distinguishing a node's
	// place within a sequence, such as a NodeList.
	ID int
	// Name is synonymous with an html tag or goquery.NodeName.
	Name string
	// Data represents the string data contained within an html node.
	Data string
	// Class represents the optional class attribute of an html node.
	Class string
}

Node represents an html node within a document.

type NodeList

type NodeList struct {
	Name  string
	Nodes []Node
}

NodeList represents a collection of Nodes with an arbitrary identifier.

func CollectionSiblings

func CollectionSiblings(alias string, searchGroups [][]string) ([]NodeList, error)

CollectionSiblings identifies arbitrary collections of HTML nodes from a datasource and returns the contents of both the identified collections and their inferred siblings.

An arbitrary collection of nodes could be [b, a, d] from a table organized as [a, b, c, d].

Furthermore, with three collections of nodes in tables sharing parent p...

p
|> [a1, b1, c1, d1]
|> [a2, b2, c2, c2]
|> [a3, b3, c3, d3]

... and the two arbitrary collections are given...

[b1, a1, d1]
[b2, a2, d2]

...the values returned will be:

[b1, a1, d1]
[b2, a2, d2]
[b3, a3, d3]

Had the third table not been the child of p, its nodes would not have been inferred as a sibling.

Each searchGroups subarray should contain a group of values expected to be within a shared structure, such as a table or table row.

Value order as given will be maintained, regardless of how the associated nodes are organized in the datasource.

func HierarchyFor

func HierarchyFor(dsAlias string, nodesContaining []string, parentLimit int) ([]NodeList, error)

HierarchyFor returns linear node hierarchies for nodes containing the given values. Value matching is performed on an OR basis. The parent limit parameters must be >= 1.

type Route

type Route struct {
	Start *html.Node
	End   *html.Node
	Steps []Step
}

Route represents a unidirectional series of steps connecting two nodes.

func (Route) AddStep

func (r Route) AddStep(s Step) Route

AddStep appends a Step to the Steps field.

func (Route) AppendRoute

func (r Route) AppendRoute(a Route) Route

AppendRoute appends the Steps field of a to the Step field of the caller.

func (Route) LastNodeInRoute

func (r Route) LastNodeInRoute() (*html.Node, error)

LastNodeInRoute returns the node resulting from navigating the caller's Steps from the caller's Start node.

func (Route) String

func (r Route) String() string

String returns a string representation of the Start, Steps, and End fields, respectively.

type Step

type Step int

Step represents a navigation option between two nodes.

const (
	Parent Step = iota
	NextSibling
	FirstChild
)

Jump to

Keyboard shortcuts

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