selector

package
v0.0.0-...-6a20a75 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeJSON identifies the currently selected type as JSON
	TypeJSON = "JSON"
	// TypeCSS identifies the currently selected type as CSS
	TypeCSS = "CSS"
	// TypeXPATH identifies the currently selected type as XPATH
	TypeXPATH = "XPATH"
	// TypeREGEX identifies the currently selected type as REGEX
	TypeREGEX = "REGEX"
	// TypeSTRING identifies the currently selected type as STRING
	TypeSTRING = "STRING"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CSSSelection

type CSSSelection struct {
	// Nodes stores the current element collection.
	Nodes *goquery.Selection
}

CSSSelection is an element set maintained by the CSS parser.

func (*CSSSelection) Attr

func (selection *CSSSelection) Attr(attr string) (string, error)

Attr is used to obtain values of specified attributes of an element It's a standard method of the selection implementation

func (*CSSSelection) Each

func (selection *CSSSelection) Each(iterator func(int, Selection) bool) error

Each is used to traverse the current elements It's a standard method of the selection implementation

func (*CSSSelection) Eq

func (selection *CSSSelection) Eq(index int) (Selection, error)

Eq is used to return the index element in the current element collection the index starts at 0 It's a standard method of the selection implementation

func (*CSSSelection) Find

func (selection *CSSSelection) Find(selector string) (Selection, error)

Find is used to find the set of elements described by the selector in the current collection of elements it returns the current element set when the selector is empty. It's a standard method of the selection implementation

func (*CSSSelection) String

func (selection *CSSSelection) String() (document string)

String method is used to return the string of all elements in the current element collection the html/xml tag in this text will not be deleted It's a standard method of the selection implementation

func (*CSSSelection) Text

func (selection *CSSSelection) Text() string

Text method is used to return the text of all elements in the current element collection the text will not contain html/xml tags and attributes It's a standard method of the selection implementation

func (*CSSSelection) Type

func (selection *CSSSelection) Type(typename string) (Selection, error)

Type method is used to convert the current Selection to other types. It's a standard method of the selection implementation

type JSONSelection

type JSONSelection struct {
	// Nodes stores the current element collection.
	Nodes *gjson.Result
}

JSONSelection is an element set maintained by the JSON parser.

func NewJSON

func NewJSON(document string) (*JSONSelection, error)

NewJSON is used to initialize a JSON Selection from the string It's a constructor function.

func (*JSONSelection) Attr

func (selection *JSONSelection) Attr(attr string) (string, error)

Attr is used to obtain values of specified attributes of an element JSONSelection does not currently support the Attr method. TODO: Implement the Attr method of JSONSelection example: {"element": "<a href=\"01.html\">Index</a>"} json("element").attr("href") => 01.html It's a standard method of the selection implementation

func (*JSONSelection) Each

func (selection *JSONSelection) Each(iterator func(int, Selection) bool) error

Each is used to traverse the current elements It's a standard method of the selection implementation

func (*JSONSelection) Eq

func (selection *JSONSelection) Eq(index int) (Selection, error)

Eq is used to return the index element in the current element collection the index starts at 0 It's a standard method of the selection implementation

func (*JSONSelection) Find

func (selection *JSONSelection) Find(selector string) (Selection, error)

Find is used to find the set of elements described by the selector in the current collection of elements it returns the current element set when the selector is empty. It's a standard method of the selection implementation

func (*JSONSelection) String

func (selection *JSONSelection) String() string

String method is used to return the string of all elements in the current element collection the html/xml tag in this text will not be deleted It's a standard method of the selection implementation

func (*JSONSelection) Text

func (selection *JSONSelection) Text() string

Text method of the JSON selector now only outputs the contents of the element collection as it is. TODO: Better way to achieve example: {"element": "<a href=\"01.html\">Index</a>"} json("element").text() => Index It's a standard method of the selection implementation

func (*JSONSelection) Type

func (selection *JSONSelection) Type(typename string) (Selection, error)

Type method is used to convert the current Selection to other types. It's a standard method of the selection implementation

type RegexSelection

type RegexSelection struct {
	// Nodes stores the current element collection.
	Nodes []string
}

RegexSelection is an element set maintained by the Regex parser.

func NewRegex

func NewRegex(document string) (*RegexSelection, error)

NewRegex is used to initialize a Regex Selection from the string It's a constructor function.

func (*RegexSelection) Attr

func (selection *RegexSelection) Attr(attr string) (string, error)

Attr is used to obtain values of specified attributes of an element RegexSelection does not currently support the Attr method. TODO: Implement the Attr method of RegexSelection It's a standard method of the selection implementation

func (*RegexSelection) Each

func (selection *RegexSelection) Each(iterator func(int, Selection) bool) error

Each is used to traverse the current elements It's a standard method of the selection implementation

func (*RegexSelection) Eq

func (selection *RegexSelection) Eq(index int) (Selection, error)

Eq is used to return the index element in the current element collection the index starts at 0 It's a standard method of the selection implementation

func (*RegexSelection) Find

func (selection *RegexSelection) Find(selector string) (Selection, error)

Find is used to find the set of elements described by the selector in the current collection of elements it returns the current element set when the selector is empty. It's a standard method of the selection implementation

func (*RegexSelection) String

func (selection *RegexSelection) String() (document string)

String method is used to return the string of all elements in the current element collection the html/xml tag in this text will not be deleted It's a standard method of the selection implementation

func (*RegexSelection) Text

func (selection *RegexSelection) Text() string

Text method of the Regex selector now only outputs the contents of the element collection as it is. TODO: Implement the Text method of RegexSelection It's a standard method of the selection implementation

func (*RegexSelection) Type

func (selection *RegexSelection) Type(typename string) (Selection, error)

Type method is used to convert the current Selection to other types. It's a standard method of the selection implementation

type Selection

type Selection interface {
	// Find is used to find the set of elements
	// described by the selector in the current collection of elements
	// it returns the current element set when the selector is empty.
	Find(string) (Selection, error)

	// Type method is used to convert the current Selection to other types.
	Type(string) (Selection, error)

	// Eq is used to return the index element in the current element collection
	// the index starts at 0
	Eq(int) (Selection, error)

	// Each is used to traverse the current elements
	Each(func(int, Selection) bool) error

	// Attr is used to obtain values of specified attributes of an element
	Attr(string) (string, error)

	// Text method is used to return the text of all elements in the current element collection
	// the text will not contain html/xml tags and attributes
	Text() string

	// String method is used to return the string of all elements in the current element collection
	// the html/xml tag in this text will not be deleted
	String() string
}

Selection is the selector interface.

func NewCSS

func NewCSS(document string) (Selection, error)

NewCSS is used to initialize a CSS Selection from the string It's a constructor function.

func NewSelection

func NewSelection(typename string, document string) (Selection, error)

NewSelection is used to initialize the selector of the specified type from the string.

func NewString

func NewString(document string) (Selection, error)

NewString is used to initialize a String Selection from the string It's a constructor function.

type StringSelection

type StringSelection struct {
	// Nodes stores the current element collection.
	Nodes []string
}

StringSelection is an element set maintained by the string parser.

func (*StringSelection) Attr

func (selection *StringSelection) Attr(attr string) (string, error)

Attr is used to obtain values of specified attributes of an element StringSelection does not currently support the Attr method. TODO: Implement the Attr method of StringSelection It's a standard method of the selection implementation

func (*StringSelection) Each

func (selection *StringSelection) Each(iterator func(int, Selection) bool) error

Each is used to traverse the current elements It's a standard method of the selection implementation

func (*StringSelection) Eq

func (selection *StringSelection) Eq(index int) (Selection, error)

Eq is used to return the index element in the current element collection the index starts at 0 It's a standard method of the selection implementation

func (*StringSelection) Find

func (selection *StringSelection) Find(selector string) (Selection, error)

Find method of StringSelection returns itself.

func (*StringSelection) String

func (selection *StringSelection) String() (document string)

String method is used to return the string of all elements in the current element collection the html/xml tag in this text will not be deleted It's a standard method of the selection implementation

func (*StringSelection) Text

func (selection *StringSelection) Text() string

Text method of the StringSelection now only outputs the contents of the element collection as it is. TODO: Implement the Text method of StringSelection

func (*StringSelection) Type

func (selection *StringSelection) Type(typename string) (Selection, error)

Type method is used to convert the current Selection to other types. It's a standard method of the selection implementation

type XpathSelection

type XpathSelection struct {
	// Nodes stores the current element collection.
	Nodes []*html.Node
}

XpathSelection is an element set maintained by the Xpath parser.

func NewXpath

func NewXpath(document string) (*XpathSelection, error)

NewXpath is used to initialize a Xpath Selection from the string It's a constructor function.

func (*XpathSelection) Attr

func (selection *XpathSelection) Attr(attr string) (conseq string, err error)

Attr is used to obtain values of specified attributes of an element It's a standard method of the selection implementation

func (*XpathSelection) Each

func (selection *XpathSelection) Each(iterator func(int, Selection) bool) error

Each is used to traverse the current elements It's a standard method of the selection implementation

func (*XpathSelection) Eq

func (selection *XpathSelection) Eq(index int) (Selection, error)

Eq is used to return the index element in the current element collection the index starts at 0 It's a standard method of the selection implementation

func (*XpathSelection) Find

func (selection *XpathSelection) Find(selector string) (_ Selection, err error)

Find is used to find the set of elements described by the selector in the current collection of elements it returns the current element set when the selector is empty. It's a standard method of the selection implementation

func (*XpathSelection) String

func (selection *XpathSelection) String() (document string)

String method is used to return the string of all elements in the current element collection the html/xml tag in this text will not be deleted It's a standard method of the selection implementation

func (*XpathSelection) Text

func (selection *XpathSelection) Text() (document string)

Text method is used to return the text of all elements in the current element collection the text will not contain html/xml tags and attributes It's a standard method of the selection implementation

func (*XpathSelection) Type

func (selection *XpathSelection) Type(typename string) (Selection, error)

Type method is used to convert the current Selection to other types. It's a standard method of the selection implementation

Jump to

Keyboard shortcuts

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