godom

package module
v0.0.0-...-8956b6f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: MIT Imports: 6 Imported by: 0

README

Build Status Go Report GoDoc

Go DOM data extraction package inspired by BeautifulSoup

DOM data extraction package with a Python BeautifulSoup like API

This package has an external dependency:

  • golang.org/x/net/html

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONArrayDelimiter = JSONDelimiter{"[", "]"}

JSONArrayDelimiter type

View Source
var JSONDictionaryDelimiter = JSONDelimiter{"{", "}"}

JSONDictionaryDelimiter type

Functions

This section is empty.

Types

type DOM

type DOM struct {
	// contains filtered or unexported fields
}

DOM Document.

func NewDOM

func NewDOM() DOM

NewDOM Constructor

func (*DOM) ChildFind

func (id *DOM) ChildFind(parent *DOMNode, tag string, attributes DOMNodeAttributes) (result []*DOMNode)

ChildFind : Find the child Node of type tag with the specified attributes

func (*DOM) ChildFindJSONForScriptWithKeyDelimiter

func (id *DOM) ChildFindJSONForScriptWithKeyDelimiter(parent *DOMNode, substring string, delimiter JSONDelimiter) (result JSONMap, err error)

ChildFindJSONForScriptWithKeyDelimiter : Find the child JSON key with delimited text containing substring

func (*DOM) ChildFindTextForClass

func (id *DOM) ChildFindTextForClass(parent *DOMNode, tag string, class string) (result string)

ChildFindTextForClass : Find the child given tag with the specified attributes

func (*DOM) ChildFindWithKey

func (id *DOM) ChildFindWithKey(parent *DOMNode, tag string, substring string) (result []*DOMNode)

ChildFindWithKey : Find the child Node of type tag with text containing key

func (*DOM) ContentLength

func (id *DOM) ContentLength() int

ContentLength : The byte count of the raw html contents.

func (*DOM) Contents

func (id *DOM) Contents() string

Contents : The raw html contents.

func (*DOM) Dump

func (id *DOM) Dump()

Dump : dump the textual representation of the DOM

func (*DOM) Find

func (id *DOM) Find(tag string, attributes DOMNodeAttributes) (result []*DOMNode)

Find : Find the Node of type tag with the specified attributes

func (*DOM) FindJSONForScriptWithKey

func (id *DOM) FindJSONForScriptWithKey(substring string) (result JSONMap, err error)

FindJSONForScriptWithKey : Find the JSON key with text containing substring

func (*DOM) FindJSONForScriptWithKeyDelimiter

func (id *DOM) FindJSONForScriptWithKeyDelimiter(substring string, delimiter JSONDelimiter) (result JSONMap, err error)

FindJSONForScriptWithKeyDelimiter : Find the JSON key with delimited text containing substring

func (*DOM) FindTextForClass

func (id *DOM) FindTextForClass(tag string, class string) (result string)

FindTextForClass : Find the given tag with the specified attributes

func (*DOM) FindWithKey

func (id *DOM) FindWithKey(tag string, substring string) (result []*DOMNode)

FindWithKey : Find the Node of type tag with text containing key

func (*DOM) IsChildNode

func (id *DOM) IsChildNode(parent *DOMNode, node *DOMNode) (result bool)

IsChildNode : Is node a child of parent? The fastest confirmation is bottom up since the relationships are one to many.

func (*DOM) IsDescendantNode

func (id *DOM) IsDescendantNode(parent *DOMNode, node *DOMNode) (result bool)

IsDescendantNode : Is node a descendant of parent? The fastest confirmation is bottom up since the relationships are one to many.

func (*DOM) RootNode

func (id *DOM) RootNode() (result *DOMNode)

RootNode : The HTML root node

func (*DOM) SetContents

func (id *DOM) SetContents(htmlString string)

SetContents : parse the raw html contents.

func (*DOM) String

func (id *DOM) String() (result string)

DOM: String representation.

type DOMNode

type DOMNode struct {
	Index         int
	Tag           string
	Attributes    DOMNodeAttributes
	TextFragments []string
	Parent        *DOMNode
	Children      []*DOMNode
}

DOMNode def

func NewDOMNode

func NewDOMNode(index int, parent *DOMNode, tag string, attributes DOMNodeAttributes) DOMNode

NewDOMNode constructor

func (*DOMNode) Attr

func (id *DOMNode) Attr(key string) string

Attr Node: String with value of the provided attribute key.

func (*DOMNode) ReaderText

func (id *DOMNode) ReaderText() (result string)

ReaderText recombines the node text fragments into the human reader visibile text

func (*DOMNode) String

func (id *DOMNode) String() (desc string)

Node: String representation.

func (*DOMNode) Text

func (id *DOMNode) Text() (result string)

Text export

type DOMNodeAttributes

type DOMNodeAttributes map[string]string

DOMNodeAttributes map of strings keyed by strings

type JSONDelimiter

type JSONDelimiter [2]string

JSONDelimiter type

type JSONMap

type JSONMap map[string]interface{}

JSONMap map of interface keyed by strings

Jump to

Keyboard shortcuts

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