goparsy

package
v0.0.0-...-54a011c Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(css string, scope Scope) string

func ConvertToType

func ConvertToType(data string, returnType string) any

func GetMultiFields

func GetMultiFields(results []*html.Node, returnType string) []any

Types

type Field

type Field struct {
	Selector     string
	SelectorType string `yaml:"selectorType"`
	Multiple     bool
	ReturnType   string `yaml:"returnType"`
	Children     map[string]Field
}

type Lexeme

type Lexeme int
const (
	SPACES Lexeme = iota
	COMMA
	UNIVERSAL
	TYPE
	ELEMENT
	CLASS
	ID
	LBRACKET
	RBRACKET
	ATTR_NAME
	ATTR_VALUE
	EQUALS
	CONTAINS_CLASS
	DASH_PREFIXED
	STARTS_WITH
	ENDS_WITH
	CONTAINS
	MATCH_OP
	PSEUDO_CLASS
	FIRST_CHILD
	FIRST_OF_TYPE
	NTH_CHILD
	NTH_OF_TYPE
	ONLY_CHILD
	ONLY_OF_TYPE
	LAST_CHILD
	LAST_OF_TYPE
	NOT
	LPAREN
	RPAREN
	COEFFICIENT
	SIGNED
	UNSIGNED
	ODD
	EVEN
	N
	OPERATOR
	PLUS
	MINUS
	BINOMIAL
	ADJACENT_TO
	PRECEDES
	PARENT_OF
	ANCESTOR_OF
	// and a counter ... I can't believe I didn't think of this sooner
	NUM_LEXEMES
)

type Parsy

type Parsy struct {
	Selectors map[string]Field
	Html      string
}

func NewParsyFromFilepath

func NewParsyFromFilepath(definitionPath string, html string) (Parsy, error)

func NewParsyFromString

func NewParsyFromString(definitionString string, html string) (Parsy, error)

func (Parsy) ExtractField

func (p Parsy) ExtractField(node *html.Node, field Field) any

func (Parsy) GetJSON

func (p Parsy) GetJSON() ([]byte, error)

func (Parsy) GetMap

func (p Parsy) GetMap() map[string]any

type Scope

type Scope int
const (
	GLOBAL Scope = iota
	LOCAL
)

Jump to

Keyboard shortcuts

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